Mac OSX installer pkg ignoring requested application display name in Applications folder, using bundle .app name stem instead

StackOverflow https://stackoverflow.com/questions/22430480

Pergunta

I have a problem with the displayed application name for my app on Mac OSX, after installation, not being as I want. This is for an app distributed as a pkg file outside of the app store. Everything works fine except for the displayed name of the application as shown in the Mac's 'Applications' folder. What is displayed is always the bundle name (without the .app) whatever I do. I had thought it would use the name I give within the Info.plist file.

This is what I am doing.

I create a bundle for my app, that contains an Info.plist that defines the bundle display name, like so:

myapp.app/
myapp.app/Contents
myapp.app/Contents/Info.plist
myapp.app/Contents/MacOS
...
myapp.app/Contents/Resources
...

Its actually a Qt based app that I build using qmake/make/macdeployqt and not using Xcode. But that should be irrelevant to my problem, I think. In my Info.plist file I have:

<?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>CFBundleIdentifier</key>
  <string>uk.co.blahdomain.MyApplication</string>
  <key>CFBundleName</key>
  <string>My Application</string>
  <key>CFBundleDisplayName</key>
  <string>My Application</string>

.....
</dict>
</plist>

I build an installer package for the app as follows:

pkgbuild --component myapp.app --version 1 --install-location /Applications component.pkg
productbuild --distribution distribution.xml --resources ./distresources --package-path . --version 1.2.3 --sign "Developer ID Installer: blah company name" test.pkg

As you can see my build processes created a myapp.app bundle folder and from that I created a .pkg using pkgbuild and productbuild. But embedded within the component package thats in the final product package is its Info.plist file that says what (I want) the displayed name to be - "My Application".

I can run the .pkg file from the Finder and it all seems to install OK.

But when I open my Applications folder (using the 'A' icon in the task bar thing) its there but NOT called 'My Application' but instead called 'myapp' which was the name of the application bundle. Its runs fine, just the displayed name that is always wrong.

So... the PROBLEM is that I want to control the name the user sees but as it contains spaces I cant use that as the name in the bundle.app.

So... how do I get the application name to show as I want within the /Applications folder and on the task bar icon?

Thanks

Foi útil?

Solução

The Finder shows file names (sometimes without extensions), not bundle names; if you want the finder to show it as "My Application", you have to name the bundle folder "My Application.app". Spaces in the name shouldn't be a problem if you quote it properly:

pkgbuild --component "My Application.app" --version 1 --install-location /Applications component.pkg

If the qmake/make/macdeployqt tools can't cope with spaces in filenames, then either

  1. Fix the tools. Spaces in filenames aren't that hard to deal with, you just have to use proper shell quoting, like wrap all variable references in double-quotes.
  2. Or, create the app bundle without spaces, then rename it before packaging it for distribution.

EDIT: The purpose of the CFBundleDisplayName key is to allow language localization of the displayed application name. Essentially, if you set it equal to the actual folder name and then include localizations for it in the Contents/Resources/somelanguage.lproj/InfoPlist.strings files, it'll display that localized name instead of the real filename. BUT, if the user renames it (which is a completely reasonable thing to do), the Finder will see the mismatch between the CFBundleDisplayName and the actual name, ignore the localization, and display the user's chosen name. See the Apple docs on CFBundleDisplayName for their explanation.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top