如何重命名 nwjs 应用程序

How to rename an nwjs app

我正在签署我的 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 时,该应用程序显示在“应用程序”下并且运行良好。但是它在Finder中的名字还是nwjs,不管我怎么改都在下面三个info.plists:

Bundle display name
Bundle name
Bundle identifier

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

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

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

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

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

  • 为您添加一个产品字符串 package.json,名称如下(重要:请勿添加字符串助手)

    {
    "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 - 将文件重命名为'your_app Helper'

  • Contents/Versions/n.n.n.n/nwjs Helper.app/Contents/Info.plist - 更改 CFBundleDisplayName = your_app Helper
  • Contents/Versions/n.n.n.n/nwjs Helper.app - 将目录重命名为“your_app Helper.app”

您可能还必须为 ...helper.app 执行触摸命令,但通常不需要。

有关更多信息,请查看 http://docs.nwjs.io/en/latest/For%20Users/Package%20and%20Distribute/ 第 Mac OS X