This post will show you how to create the simplest possible installer package with pkgbuild.
Making a simple installer is actually easy, but Apple only provides us with a man page and most tutorials dive too deep straight away.
That's not great. It's an intimidating tool. Let's start with the basics.
What does pkgbuild do?
pkgbuild packs your app's files into bare-bones .pkg packages. They are bare-bones because they don't have any of the fancy features like license or readme sections.
The bare-bones packages are actually called component packages, but don't let the "component" part fool you. It's fine to distribute your app as a component package. This is what you'll see if you open one:
A perfectly normal installer.
How to build a component package with pkgbuild
You can put your all of your app's files in a single component package. You just have to tell pkgbuild where everything goes.
Let's start with the basic scenario. An application bundle called MyApp.app that should be installed into /Applications.
The easiest way to tell pkgbuild where things should go is to make a fake root folder. That's just a folder that mimics the end result that your installer will create.
For example, if you want to end up with /Applications/MyApp.app, you prepare it inside some other folder like this: /tmp/MyAppRoot/Applications/MyApp.app. In this case, /tmp/MyAppRoot is the fake root folder. It doesn't matter how you name your fake root folder or where you put it.
Now you can call pkgbuild and point it to the fake root folder where you copied your app's files. The last parameter is the filename you want for the installer itself.
$ cd /tmp $ pkgbuild --root MyAppRoot MyInstaller.pkg
Packages install to the system, not to home directories. If an application needs to create objects in the user's home directory, it should do so itself when it is first launched, not when it is installed.
How to: Making OS X Installer Packages like a Pro - Xcode4 Developer ID Mountain Lion ready pkg
How to: Making OS X Installer Packages like a Pro – Xcode4 Developer ID Mountain Lion ready pkg
Making OS X Installer Packages like a Pro – Xcode4 Developer ID Mountain Lion ready pkg
Note: This is for OS X Installer packages only, packages for submission to the Mac App Store follow different rules.
Because of Mountain Lions Gatekeeper I finally had to take my PackageMakerbuild script behind the barn and shoot it. PackageMaker was already removed from Xcode and moved into “Auxiliary Tools…