如何重命名nwjs应用程序

3

我正在使用 nwjs 应用进行签名,并使用 productbuild 命令进行打包。

当我安装应用后,它会显示在“应用程序”下并正常工作,但在“Finder”中显示的名称仍然是 nwjs。如何将其更改为我的应用程序名称?

签名脚本:

identity="3rd Party Mac Developer Application: my comp..."
app="nwjs.app"
rm -f "$app/Icon^M" 
rm -r -f "$app/.idea"

echo "### signing libraries"
codesign --force --verify --sign "$identity" "$app/Contents/Versions/64.0.3282.186/libffmpeg.dylib"
codesign --force --verify --sign "$identity" "$app/Contents/Versions/64.0.3282.186/nwjs Framework.framework/libnode.dylib"

echo "### signing frameworks"
codesign --force --verify --sign "$identity" "$app/Contents/Versions/64.0.3282.186/nwjs Framework.framework/Versions/A/XPCServices/AlertNotificationService.xpc"
codesign --force --verify --sign "$identity" "$app/Contents/Versions/64.0.3282.186/nwjs Framework.framework/Versions/A/Helpers/crashpad_handler"
codesign --force --verify --sign "$identity" "$app/Contents/Versions/64.0.3282.186/nwjs Framework.framework/nwjs Framework"
codesign --force --verify --sign "$identity" "$app/Contents/Versions/64.0.3282.186/nwjs Framework.framework/Helpers/crashpad_handler"
codesign --force --verify --sign "$identity" "$app/Contents/Versions/64.0.3282.186/nwjs Helper.app/Contents/MacOS/nwjs Helper"
codesign --force --verify --sign "$identity" "$app/Contents/Versions/64.0.3282.186/nwjs Helper.app/"

echo "### sing osx folder"
codesign --force --verify --sign "$identity"  "$app/Contents/MacOS/nwjs"

echo "### signing app"
codesign --force --verify --sign "$identity" "$app"

它无错误地签署,我可以打开已签名的应用程序,它可以正常运行。然后打包它:

productbuild --sign "3rd Party Mac Developer Installer: mycomp..." --component "nwjs.app" /Applications --product "nwjs.app/Contents/Info.plist" MyApp.pkg

当我安装生成的pkg时,应用程序会出现在“应用程序”下,并且可以正常工作。但是无论我在以下三个info.plists中尝试更改什么,它在Finder中的名称仍然是nwjs:
Bundle display name
Bundle name
Bundle identifier

in

Contants/Info.plist
Contents/Resources/app.nw//Info.plist
Contents/Versions/57.0.2987.133/nwjs Helper.app/Contents/Info.plist

最近一个版本的更改导致应用程序在启动时崩溃。

版本:

nwjs-sdk-v0.28.3-osx-x64
os: mac high Sierra 10.13.3
1个回答

3
首先,要使用签名脚本(由我编写;)),您需要更改路径。Contents/Versions/64.0.3282.186必须更改为您所拥有的版本的路径。我猜测Contents/Versions/57.0.2987.133/

如果您想更改名称,您可能还需要更改。 Contents/Resources/en.lproj/InfoPlist.strings - CFBundleDisplayName 我已将其删除。

苹果不会立即识别它。为了加快速度,您可以进入终端并执行以下命令。"touch your_app.app" 苹果现在重置此应用程序的已知参数。

如果您想更改nwjs helper.app的名称,则必须执行以下操作。

  • Add a product string to you package.json with the name like this (Important: DO NOT ADD THE STRING HELPER)

    {
    "name": "your_app",
    "version": "0.0.1",
    "main": "index.html",
    "window": {
      "width": 1150,
      "height": 650,
      "show_in_taskbar": true
    },
    "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
    },
    "product_string": "your_app", //THIS IS WHAT YOU ADD
    "dependencies": {
    }
    }
    
  • Contents/Versions/n.n.n.n/nwjs Helper.app/Contents/MacOS/nwjs Helper - rename the file to ‘your_app Helper’

  • Contents/Versions/n.n.n.n/nwjs Helper.app/Contents/Info.plist - change CFBundleDisplayName = your_app Helper
  • Contents/Versions/n.n.n.n/nwjs Helper.app - rename the directory to ‘your_app Helper.app’
你可能还需要使用 touch 命令来处理 ...helper.app,但通常不需要。如需更多信息,请查看Mac OS X部分。

谢谢,还有脚本 :-) 对我有用的是删除Contents/Resources/中的所有lproj文件。 - jerry
很高兴能够帮助。您介意将答案标记为正确吗?还是我需要更新一些内容 ;) - Silve2611
顺便问一下,你知道即使设置了"window": { "show":false},在Windows上仍会出现nwjs启动画面的原因吗?如果你愿意,我可以单独询问。 - Sandburg
什么是启动画面? - Silve2611

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接