Tips & Tricks: How to Archive and Export .ipa from Script

  November 25, 2014

As you might have experienced it is slightly different to export .ipa file with Xcode 6 (and especially 6.1). In the prior versions, it used to work out of the box when you had the right provisioning profile and distribution certificate within your environment. Furthermore, using Xcode 6 you need to have your user account compatible with the Developer Program to make distribution builds. In this quick blog post, we’d like to share one tip and trick to help you quickly archive and export .ipa from the script.


What used to work well with older Xcode versions ( < 6) aren’t the case anymore. But, starting from Xcode 5 the xcodebuild has included a parameter for exporting from the archive. To do distribution builds, this can be used to create builds without actual dependencies to provisioning.

Getting Started with xcodebuild

First, create a build script. The proposed build script could start by a clean and followed with performing an archived call:

xcodebuild clean -project <PROJECT_NAME>.xcodeproj -configuration Release -alltargets
xcodebuild archive -project <PROJECT_NAME>.xcodeproj -scheme <NAME_OF_SCHEME> -archivePath <PROJECT_NAME>.xcarchive

For example, this is how you would use it with Bitbar sample app (for Calabash):

xcodebuild clean -project BitbarIOSSample.xcodeproj -configuration Release -alltargets
xcodebuild archive -project BitbarIOSSample.xcodeproj -scheme BitbarIOSSample-cal -archivePath BitbarIOSSample.xcarchive

NOTE! -cal is a scheme under BitbarIOSSample and can be renamed/called whatever.

Archive and Export .ipa file

Export the archive into a .ipa file using the following command:

xcodebuild -exportArchive -archivePath <PROJECT_NAME>.xcarchive -exportPath <PROJECT_NAME> -exportFormat ipa -exportProvisioningProfile "Name of Provisioning Profile"

Again, this is how you would use it with Bitbar sample app (for Calabash):

xcodebuild -exportArchive -archivePath BitbarIOSSample.xcarchive -exportPath BitbarIOSSample-cal -exportFormat ipa -exportProvisioningProfile "iOSTeam Provisioning Profile: *"

Furthermore, you can specify the signing identity using the -exportSigningIdentity parameter (if needed).

Also, you need to specify the name of the provisioning profile as defined in the file itself. This must be the same name assigned to the profile in the provisioning portal.