Mac package installer installs the folder “Contents” in /Applications instead of the bundle

build-versioninstallpackage-managementpkg

When I try to use packaging with my .app to create a Mac installer, and I run the installer, it creates me a folder named "Contents" in my /Applications folder, instead the "bundle app" as it should.

I've test with pkgbuild + productbuild:

pkgbuild --component "./myapp.app" --version 1 --install-location /Applications component.pkg
productbuild  --package-path "component.pkg" --distribution "./Distribution.xml" --package-path "./Temp" --resources "./Resources" --sign mycert "myapp.pkg"

And just with productbuild:

productbuild --component "./myapp.app" /Applications -s mycert myapp.pkg

In both cases, I run the installer, everything seems fine, but in Applications folder I see "Contents" (that is the content of the app bundle)

I've tried with "./myapp.app/" also in –component attribute, and even adding "/Applications/myapp.app" in the –install-location

Best Answer

Took me a few tries to get this working (the installer managed to do some really strange stuff on my first few attempts). But this seems to work reliably.

I created a temporary folder with just the application I wanted to package (leaving the app sitting elsewhere seemed to result in the aforementioned strange behaviour), then package it from there. So I created a temporary folder called "test" on my desktop and dropped the app in there on its own. The following command then reliably results in a working package on my Desktop.

productbuild --component ~/Desktop/test/myapp.app /Applications ~/Desktop/myapp.pkg --sign "my certificate identity name"

Something that is helpful when testing is to run sudo opensnoop | grep installd in a Terminal at the same time. It generates a lot of output but you should be able to see the application bundle being created in something like /var/folders/zz/GIBBERISH/C/PKInstallSandboxManager/GIBBERISH.activeSandbox/Root/ and then copied to its final destination.

Note: I'm not certain why you are using -s in the second example productbuild command you gave in your question. There are three options arguments to productbuild that start with "s" (synthesis, scripts and sign) and the man page doesn't mention using the shorter "-s" for any of them. Perhaps this is the problem. Of course it could just be a typo. :)