Xcode 3.2 provides an awesome new feature under the Build menu, \"Build and Archive\" which generates an .ipa file suitable for Ad Hoc distribution. You can also open the O
The xcodebuild
tool can build and export archive products with the -exportArchive flag (as of Xcode 5). The export step was previously only possible via the Xcode Organizer UI.
First archive your app:
xcodebuild -scheme <scheme name> archive
Given $ARCHIVE_PATH
(the path to the .xcarchive file), export the app from the archive with one of the following:
iOS .ipa file:
xcodebuild -exportArchive -exportFormat ipa -archivePath "$ARCHIVE_PATH" -exportPath "myApp.ipa" -exportProvisioningProfile "My App Provisioning profile"
Mac .app file:
xcodebuild -exportArchive -exportFormat app -archivePath "$ARCHIVE_PATH" -exportPath "myApp.app" -exportSigningIdentity "Developer ID Application: My Software Company"
In both commands the -exportProvisioningProfile and -exportSigningIdentity arguments are optional. man xcodebuild
for details on the semantics. In these examples, the provisioning profile for the iOS build specified an AdHoc distribution provisioning profile, and the signing identity for the Mac app specified a Developer ID for export as a 3rd party application (i.e. not distributed via the Mac App Store).
cd /Users/username/Desktop/demo/
xcodebuild archive -project demo.xcodeproj -scheme demo -archivePath /Users/username/Desktop/demo.xcarchive
xcodebuild -workspace Project-Name.xcworkspace -scheme Scheme-Name -sdk iphoneos -configuration Release Provisioning_Profile=“Provision-Name” Development_Team=“Team-ID” archive -archivePath /Path/To/Output/AppName.xcarchive archive
xcodebuild -exportArchive -archivePath /Users/shilpa/Desktop/demo.xcarchive -exportPath /Users/shilpa/Desktop/demo.ipa -exportOptionsPlist /Users/shilpa/Downloads/ExportOptions.plist
I've been using my own build script to generate the ipa package for ad hoc distribution.
die() {
echo "$*" >&2
exit 1
}
appname='AppName'
config='Ad Hoc Distribution'
sdk='iphoneos3.1.3'
project_dir=$(pwd)
echo using configuration $config
echo updating version number
agvtool bump -all
fullversion="$(agvtool mvers -terse1)($(agvtool vers -terse))"
echo building version $fullversion
xcodebuild -activetarget -configuration "$config" -sdk $sdk build || die "build failed"
echo making ipa...
# packaging
cd build/"$config"-iphoneos || die "no such directory"
rm -rf Payload
rm -f "$appname".*.ipa
mkdir Payload
cp -Rp "$appname.app" Payload/
if [ -f "$project_dir"/iTunesArtwork ] ; then
cp -f "$project_dir"/iTunesArtwork Payload/iTunesArtwork
fi
ipaname="$appname.$fullversion.$(date -u +%Y%m%d%H%M%S).ipa"
zip -r $ipaname Payload
echo finished making $ipaname
The script also increment the version number. You can remove that part if it's not needed. Hope it helps.
Go to the folder where's your project root and:
xcodebuild -project projectname -activetarget -activeconfiguration archive
Going one step further, uploading to iTunesConnect via commandline with Xcode 7!
(Assuming you are starting with an .ipa
that has been signed with the correct release profile and signing identity.)
Enter altool
, the CLI interface for the Application Loader (docs, page 38).
Hidden deep within Xcode.app's structure, is a handy function to let us upload directly to ItunesConnect.
/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool
Simply run $ altool --upload-app -f file -u username [-p password]
to upload your newly minted .ipa
straight to Apple.
The password is optional, and will prompt you for it if you leave it off the command.
If there are any issues with the app during the verification step, the console will print them out.
You will likely have to export the path to altool
if you don't want to save its location.
export PATH=$PATH:/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/
Thats it! Simply login to iTunesConnect.com and select your new build for testing with testflight.
Final Note: If you get an error saying Exception while launching iTunesTransporter: Transporter not found at path: /usr/local/itms/bin/iTMSTransporter. You should reinstall the application
, you can follow the suggestion on this SO answer, to run a symlink to the correct location:
ln -s /Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/itms /usr/local/itms
After updating to Xcode 8, I found that enterprise ipa generate by
/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}"
Command cannot be launched because of some signature issue. The log indicates that "warning: PackageApplication is deprecated, use
xcodebuild -exportArchive
instead.
So I switch to xcodebuild -exportArchive
and everything went back normal.