Automating Over The Air Deployment for iPhone

Automating Over The Air Deployment for iPhone

Since the release of the iOS4 we are able to distribute iPhone applications “Over The Air” (i.e: directly downloading the application from the iPhone without using iTunes).
This greatly simplifies the deployment process especially for entreprises where iTunes is rarely a corporate tool. It also allows you to create your own enterprise App Store.
But until now it was a fully manual process : not anymore !
In this article we’ll see how to automate the deployment with a software factory, thus making the deployment more reliable and more productive.

The missing command line :

Over the air deployment is based on a new command in the build menu of Xcode called “build and archive” which packages the application with an embedded provisioning profile.
There have been many questions on how to integrate this feature in a continuous integration process.

The “xcodebuild” command is well known : it builds an Xcode project from the command line and generates an “.app” file.

You can use this command to build your application from a script ran by a software factory.
But the generated file cannot be distributed over the air since it misses the embedded provisioning profile.
We need to build the project into an “.ipa” file, containing the provisioning profile and signed with your developper identity.

To be able to find the command line, the trick was to watch the system console log while running a “build and archive” through Xcode. You will then see something similar to this :

Console log extract :
31/10/10 20:57:16 Xcode[16510] Running /usr/bin/xcrun with (
“/Users/barbu/Library/MobileDevice/Archived Applications/FDA8B2FA-5AE1-43E7-BF9F-CD32FD258907.apparchive/”,
“/Users/barbu/Library/MobileDevice/Archived Applications/FDA8B2FA-5AE1-43E7-BF9F-CD32FD258907.apparchive/TestTemplate.ipa”,
“iPhone Developer: M VINCENT DAUBRY (J9TS3TJRYX)”,
“/Users/barbu/Library/MobileDevice/Provisioning Profiles/68D899AB-9FEB-4CBB-A080-1078FF2FABCF.mobileprovision”

Writing the script :

You can now run a script which will :

  • Build your application into an .app file
 xcodebuild -target "${PROJECT_NAME}" -sdk "${TARGET_SDK}" -configuration Release
  • Package it into an .ipa file
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${RELEASE_BUILDDIR}/${APPLICATION_NAME}.app" -o "${BUILD_HISTORY_DIR}/${APPLICATION_NAME}.ipa" --sign "${DEVELOPER_NAME}" --embed "${PROVISONING_PROFILE}”

Here is a sample build script.

EDIT: June 13th, 2012

Since this article has been published, the industrialization of iOS development has been improved. Specially with the release of the XCode plugin for Jenkins.

One year ago, OCTO launched the Appaloosa service, the private store service to help our teams, our customers and anybody who needs to go further with the Over-The-Air distribution of their private apps.

Appaloosa provides its own Jenkins plugin to automatically deploy the latest version of an application to the private store.