Generate an ipa from the command-line

1 minute read

The article Configuring XCode Project Signing with xcconfig describes setting up an XCode project for manual signing with xcconfig. This article uses the same project and describes how to generate an ipa from the command-line.

Before you jump to the command-line, make sure that the Xcode project Archive setting is configured correctly.

Verify archive setting

The XCode project’s Debug configuration is set to use xcconfig. By default, XCode sets the scheme’s Archive phase to the Release configuration. To modify the Archive phase setting, edit the XCConfig Signing scheme and choose Archive.

Before scheme update

Update the Build Configuration to Debug from the dropdown then click Close to close the dialog. The XCConfig Signing scheme is now set to the Debug configuration for archiving.

Scheme updated

Launch Terminal and navigate to the folder where your xcodeproj file is located.

Generate an ipa

xcodebuild is a command-line tool that allows you to perform various operations on your Xcode projects and workspaces from the command line. To generate an ipa, execute the archive and export operations in sequence.

1. Archive app

To archive the app, run the following command from the Terminal.

xcodebuild -project <your-project-name>.xcodeproj -scheme <scheme name> -archivePath <path/to/your/app>.xcarchive archive

The command applied to the project is as shown.

xcodebuild -project XCConfig\ Signing.xcodeproj -scheme "XCConfig Signing" -archivePath out/myapp.xcarchive archive

myapp.xcarchive is generated in the out folder.

xcarchive-out

2. Export archive to ipa

To export the archive to an ipa, run the following command from the Terminal.

xcodebuild -exportArchive -archivePath <path/to/your/app>.xcarchive -exportPath <path/to/ipa/output/folder> -exportOptionsPlist <path/to/ExportOptions>.plist

The exportOptionsPlist is a plist file that configures archive exporting. You can download the export-options.plist template and modify it with your profile and certificate settings.

The command applied to the project is as shown.

xcodebuild -exportArchive -archivePath out/myapp.xcarchive -exportPath out -exportOptionsPlist export.plist

XCConfig Signing.ipa, DistributionSummary.plist, ExportOptions.plist, and Packaging.log are generated in the out folder.

ipa-out

Voila! You are now able to take a manually-signed XCode project using xcconfig and generate an ipa from the command-line. Happy developing!!