Tips&Tricks: How to archive and export .ipa from script

How to Use Xcode to Build IPA

Dear Testdroiders,

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 have your user account compatible with Developer Program to make distribution builds <Read more>.

xcode-icon

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 archive. To do distribution builds, this can be used to create builds without actual dependencies to provisioning.

Getting Started with xcodebuild

First, create yourself a build script. The proposed build script could start by a clean and followed with performing an archive 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.

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.

Happy iOS Building y’all!

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close