From Xcode to TestFlight using command line

So you created your app and, with a click on a play button, the app goes to your phone. But how do you manage to deliver the app for Q&A team? You take all iPhones and publish your app one by one every release you have? What if your testers get a push notification on their iPhones for every update on the app? Much better, right?


With few command lines and a automation tool (e.g jenkins), we managed to automatically deliver a new version of the app to Q&A team for every push we get on our release branch on github.

Before the command lines…

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>{your team ID}</string>
<key>teamName</key>
<string>{your team name}</string>
</dict>
</plist>

All set? Let's play!

  1. Set a new build version

Tesflight only allows you to publish one app per version number. That said, we need to increment our build number before anything else. Since we use Jenkins, we read app version from Info.plist and concat it with Jenkins build number.

v=$(/usr/libexec/PlistBuddy -c “Print :CFBundleShortVersionString” {your project name}/Info.plist)
agvtool new-version -all “${v}.$BUILD_NUMBER”

2. Clean the project

Basic lesson on iOS development: always clean your project!

xcodebuild -project {your project name}.xcodeproj -scheme {your release scheme name} -sdk iphoneos -configuration Release clean

3. Archive the project

xcodebuild -project {your project name}.xcodeproj -scheme {your release scheme name} iphoneos -configuration Release archive -archivePath “../build/{your project name}.xcarchive”

4. Export the .ipa file

Here, you'll need the exportOptions.plist created before.

xcodebuild -exportArchive -archivePath ../build/{your project name}.xcarchive -exportOptionsPlist exportOptions.plist -exportPath “../build” -allowProvisioningUpdates

5. Finally, publish you app!

cd /Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/
./altool — upload-app -f {abs path to your project}/build/{your release scheme name}.ipa -u {apple id to publish the app} -p {password of apple id}

Celebrate it! Now your app is on Testflight! 🎉


That's it. Hope it helps. Good luck! o/