Lance Pollard
Lance Pollard

Reputation: 79420

How to customize and test executable path, main icon, and i18n of a MacOS .app bundle

I have a MacOS app bundle bare bones working. That is, it runs the executable, that's it. Icon still isn't working even though I have an MyApp.icns file I can visually see in Finder. And i18n isn't working.

MyApp.app/
  Contents/
    Info.plist
    MacOS/
      MyApp # executable
    Resources/
      MyApp.icns
      en.lproj
        InfoPlist.strings
      jp.lproj
        InfoPlist.strings

The .icns I generated from here:

mkdir MyIcon.iconset
sips -z 16 16     foo.png --out MyIcon.iconset/icon_16x16.png
sips -z 32 32     foo.png --out MyIcon.iconset/[email protected]
sips -z 32 32     foo.png --out MyIcon.iconset/icon_32x32.png
sips -z 64 64     foo.png --out MyIcon.iconset/[email protected]
sips -z 128 128   foo.png --out MyIcon.iconset/icon_128x128.png
sips -z 256 256   foo.png --out MyIcon.iconset/[email protected]
sips -z 256 256   foo.png --out MyIcon.iconset/icon_256x256.png
sips -z 512 512   foo.png --out MyIcon.iconset/[email protected]
sips -z 512 512   foo.png --out MyIcon.iconset/icon_512x512.png
cp Icon1024.png MyIcon.iconset/[email protected]
iconutil -c icns MyIcon.iconset
rm -R MyIcon.iconset

My Info.plist is like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>CFBundleDevelopmentRegion</key>
  <string>en</string>

  <key>CFBundleName</key>
  <string>MyApp</string>

  <key>CFBundleDisplayName</key>
  <string>MyApp</string>

  <key>CFBundleIdentifier</key>
  <string>MyApp</string>

  <key>CFBundleVersion</key>
  <string>1.0.0</string>

  <key>CFBundleVersion</key>
  <string>APPL</string>

  <key>CFBundleSignature</key>
  <string>MyApp</string>

  <key>CFBundleExecutable</key>
  <string>this/has/no/effect</string>

  <key>CFBundleIconFile</key>
  <string>NeitherDoesThis</string>
</dict>

The InfoPlist.strings for each language looks like this:

CFBundleDisplayName = "Foo";
NSHumanReadableCopyright = "Copyright © 2019 Me.";

or:

CFBundleDisplayName = "ふ";
NSHumanReadableCopyright = "著作権法 © 2019 目.";

The problems I'm having are:

Wondering if one could verify that stuff, and show how to test the other things. Specifically:

  1. Verify that you can't actually customize the path of the executable, it must be named the same as the app in the MacOS folder.
  2. Verify that you must name the icon the same as the app, with .icns extension. I'm not sure this is true because for example Skypes main Icon is in the Resources/Skype Blue.icns location, and they say Skype Blue in the Info.plist. Wondering why I can't get this working.
  3. How to test that i18n works. Wondering if I just change the Mac system language and open the app again, etc.

This is all without using XCode.

Upvotes: 1

Views: 316

Answers (1)

l&#39;L&#39;l
l&#39;L&#39;l

Reputation: 47264

In the Info.plist missing/incorrect keys/strings can affect the first two concerns; if keys are duplicated, missing, or set incorrectly it can certainly cause issues with functionality.

  1. Missing

    • NSPrincipalClass
    • CFBundleInfoDictionaryVersion
    • CFBundleSupportedPlatforms
    • CFBundlePackageType
    • CFBundleExecutable (this is the binary inside MacOS folder)
    • CFBundleLocalizations (optional)
    • DTXcode (optional)
    • DTPlatform (optional)
    • DTSDK (optional)
    • DTCompiler (optional)
  2. Incorrect

    • CFBundleIdentifier (should be in reverse DNS format)
    • CFBundleVersion (duplicate/incorrect)
    • CFBundleSignature (incorrect)

NOTES: The application name MyApp.app does not need to be the same as the executable file inside the MacOS folder as long as you've added and set the key CFBundleExecutable. The application icon can be any name you want as well, the key to having it work is by including the additional CoreFoundation keys shown above set correctly.

Once you've got all the missing/incorrect keys sorted you should end up with something similar to:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleExecutable</key>
    <string>MyApp</string>
    <key>CFBundleIconFile</key>
    <string>MyIcon</string>
    <key>CFBundleIdentifier</key>
    <string>com.company.MyApp</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>MyApp</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSupportedPlatforms</key>
    <array>
        <string>MacOSX</string>
    </array>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>DTCompiler</key>
    <string>com.apple.compilers.llvm.clang.1_0</string>
    <key>DTPlatformBuild</key>
    <string>10B61</string>
    <key>DTPlatformVersion</key>
    <string>GM</string>
    <key>DTSDKBuild</key>
    <string>18B71</string>
    <key>DTSDKName</key>
    <string>macosx10.14</string>
    <key>DTXcode</key>
    <string>1010</string>
    <key>DTXcodeBuild</key>
    <string>10B61</string>
    <key>LSMinimumSystemVersion</key>
    <string>10.13</string>
    <key>NSHumanReadableCopyright</key>
    <string>Copyright © 2019 MyApp. All rights reserved.</string>
    <key>NSMainNibFile</key>
    <string>MainMenu</string>
    <key>NSPrincipalClass</key>
    <string>NSApplication</string>
</dict>
</plist>

*The Info.plist above should work with your app, as the values are set to what you've shown in your question.


Regarding i18n testing — the Internationalization and Localization Guide the sections Testing Your Internationalized App and Managing Strings Files Yourself should be helpful. There's a huge amount of information within the Guide; a one size fits all approach to testing usually won't do so you'll want to find what works best for you.

Information Property List Key Reference
About Internationalization and Localization

Upvotes: 2

Related Questions