pkgbuild created package does not install correctly

Have now used pkgbuild/productbuild to create a product archive, consisting of three packages (application, uninstaller, KEXT), that according to installer installs fine, no errors.

The KEXT is correctly placed in /Library/Extensions and postinstall script loads it nicely.

But my applications are not moved to the /Applications/Company/ folder. The folder is created, but the applications are not placed there.

The process of doing the component plist + distribution XML is so utterly simple so I just cannot fathom what the h*ll can go wrong ?

The package can be "installed" via Pacifist, albeit then the postinstall script is not executed.

Help?

Update:

Analyze phase (application resides in ./pkgbuild/app_path/ folder):

pkgbuild --analyze --root "./pkgbuild/app_path/" app.plist

Build phase:

pkgbuild --root "./pkgbuild/app_path/" \
         --component-plist ./app.plist \
         --install-location "/Applications/Company/" \
         --identifier "com.company.myapp.pkg" \
         --version "1.0" \
         app.pkg

Then the product archive, step 1:

productbuild --synthesize --package app.pkg distribution.xml

distribution.xml is then modified with correct background image, license, etc.

Step 2:

productbuild --distribution ./distribution.xml output.pkg

(I omitted the KEXT package as that works perfectly)

When installing "output.pkg", folder /Applications/Company/ is created but is empty.

SOLVED (see Grahams answer below):

By setting BundleIsRelocatable in the component plist files to false, the applications are put into the correct place.

Viewing the installer log, the application got "relocated" to where my Xcode project built the app, but still create the /Application/Company folder. A "slightly" peculiar behaviour I would say.

OSX version is 10.11.1.


Moved Applications

The Installer is likely updating the first copy of the application it finds and not the application in the default install location.

This behaviour is deliberate and allows users to move applications, while retaining the ability to use Installer packages to apply updates.

As a developer you probably have numerous copies of the target application on your Mac. It is likely the last copy you – or Xcode – launched is the one being updated. This can include copies within hidden build folders.

Enforce the Location with BundleIsRelocatable

Setting BundleIsRelocatable flag to false forces Installer.app to use the exact path provided by the package.

Without this flag set, the Installer.app will search the target Mac for matching applications and write the new copy to the discovered location.

  • Try your installer with a clean Mac with a fresh copy of OS X.
  • Look closely at the log output from Installer.app or installer; you will see entries regarding the search and final location of the relocated application.

Report the Bug

That the Installer still created the parent company folder does feel like an error. Please report a bug with Apple.