jerry
jerry

Reputation: 155

How to rename an nwjs app

I'm signing my nwjs app and package it with a productbuild command

When I install the app it shows up under Applications and works, but it's name in the Finder is still nwjs. How can I change this to my app's name?

Signing script:

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"

It signs without errors and I can open the signed app, it works. Then package it:

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

When I install the resulting pkg, the app shows up under Applications and works well. But its name in the Finder is still nwjs, no matter what I try to change in the following three info.plists:

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

Changes in the last one makes the app crash at start up.

Version:

nwjs-sdk-v0.28.3-osx-x64
os: mac high Sierra 10.13.3

Upvotes: 3

Views: 730

Answers (1)

Silve2611
Silve2611

Reputation: 2278

First of all to use the sign script (written by me ;) ) you need to change the paths. Contents/Versions/64.0.3282.186 has to be changed to the path of the version you have. I guess Contents/Versions/57.0.2987.133/

If you want to change the name you might also have to change. Contents/Resources/en.lproj/InfoPlist.strings - CFBundleDisplayName I deleted it.

Apple does not recognize that immediately. To speed this up you can go to the terminal and do the following command. "touch your_app.app" Apple resets the know parameters for this app now.

If you want to change the name of the nwjs helper.app you have to do the following.

  • 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’

You might also have to do the touch command for the ...helper.app but usually u don't.

For more Infos look a http://docs.nwjs.io/en/latest/For%20Users/Package%20and%20Distribute/ Section Mac OS X

Upvotes: 3

Related Questions