Building for the Mac app store

17th March 2011

I recently did the development work to update Smart Shooter for submission to the Mac app store. There is already a Mac version of Smart Shooter, but the build process uses qmake (from the Qt SDK) and makefiles, and hence does not use Apple’s Xcode IDE at all.

There are valid reasons for this. The build process for the Windows version is very similar which makes it easier to manage; there qmake and nmake are used, avoiding the Visual Studio IDE completely.

The first recommendation is to download the latest version of Xcode (currently at version 4), and when installing make sure you do not uncheck the option to install the iOS SDK. I did this the first time round, and then found out that the ‘Application Loader’ tool is then not installed, which is required for uploaded your app for submission.

A Xcode project does a few extra build steps when building an application for the Mac app store, so these now have to be done manually, as stated in Apple’s developer documention.

codesign

The application bundle has to first be signed with the developer certificate that you’ve registed with Apple. This is done using the codesign tool:

codesign -f -v -s "3rd Party Mac Developer Application: Hart Codeworks" "SmartShooter.app"

If successful it will print something like:

SmartShooter.app: signed bundle with Mach-O thin (i386) [com.hartcw.SmartShooter]

productbuild

The application bundle then has to be processed by the productbuild tool. Note the certicate name is different – ‘Installer’ instead of ‘Application’, so make sure you have registered both types of certificate with Apple.

productbuild --component "SmartShooter.app" /Applications --sign "3rd Party Mac Developer Installer: Hart Codeworks" --product "SmartShooter.app/Contents/Info.plist" SmartShooter.pkg

This will create the .pkg file, which is ready to upload for submission:

productbuild: Adding component at /Users/francis/Code/hg/smartshooter/applications/smartshooter/output/mas/release/SmartShooter.app
productbuild: Signing product with identity "3rd Party Mac Developer Installer: Hart Codeworks" from keychain /Users/francis/Library/Keychains/login.keychain
productbuild: Adding intermediate certificate "Apple Worldwide Developer Relations Certification Authority"
productbuild: Wrote product to SmartShooter.pkg

installer

To test the resulting package, you must install it using the same process as if it was downloaded from the Mac app store:

sudo installer -store -pkg SmartShooter.pkg -target /

This will install the application in the /Application directory. If it relocates to a different directory, such as the original build directory, then don’t worry: this is because the installer has detected an existing application bundle, and so choose this location over the /Applications directory. For peace of mind you can delete all copies of the app bundle and retry the installer.

installer: SmartShooter.pkg has valid signature for submission
installer: Installation Check: Passed
installer: Volume Check: Passed
installer: Bundle com.hartcw.SmartShooter will be relocated to /Applications/SmartShooter.app
installer: Starting install
installer: Install 0.0% complete
installer: Install 14.2% complete
installer: Install 19.9% complete
installer: Install 28.4% complete
installer: Install 33.2% complete
installer: Install 37.3% complete
installer: Install 41.0% complete
installer: Install 100.0% complete
installer: Finished install

blog comments powered by Disqus