Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fictorial/1354187 to your computer and use it in GitHub Desktop.
Save fictorial/1354187 to your computer and use it in GitHub Desktop.
Xcode 4 scheme Archive step Post-script for automatic TestFlight build uploading. See the blog post here: http://developmentseed.org/blog/2011/sep/02/automating-development-uploads-testflight-xcode
# https://testflightapp.com/account/
API_TOKEN=XXX
# https://testflightapp.com/dashboard/team/edit/
TEAM_TOKEN=XXX
# Whatever you use for Adhoc
SIGNING_IDENTITY="iPhone Distribution: XXX"
# Organizer > Devices > Provisioning Profiles > Ad Hoc then Reveal in Finder
PROVISIONING_PROFILE="${HOME}/Library/MobileDevice/Provisioning Profiles/XXX.mobileprovision"
ROOT="${HOME}/Library/Developer/Xcode/Archives/$( /bin/date +"%Y-%m-%d" )"
ARCHIVE="$ROOT/$( /bin/ls -t "$ROOT" | /usr/bin/grep xcarchive | /usr/bin/sed -n 1p )"
DSYM="$ARCHIVE/dSYMs/$( /bin/ls -t "$ARCHIVE/dSYMs" | /usr/bin/sed -n 1p )"
APP="$ARCHIVE/Products/Applications/$( /bin/ls -t "$ARCHIVE/Products/Applications" | /usr/bin/sed -n 1p )"
LOG="/tmp/testflight.log"
/bin/rm -f $LOG
echo "Starting Ad Hoc Build and Upload Process" > $LOG
/usr/bin/open -a /Applications/Utilities/Console.app $LOG
echo "Creating IPA ... " >> $LOG
/bin/rm -f /tmp/app.ipa
/usr/bin/xcrun -sdk iphoneos PackageApplication \
-v "${APP}" \
-o /tmp/app.ipa \
--sign "${SIGNING_IDENTITY}" \
--embed "${PROVISIONING_PROFILE}"
echo "done." >> $LOG
echo "Zipping .dSYM ..." >> $LOG
/bin/rm -f "/tmp/app.dSYM.zip"
/usr/bin/zip -r "/tmp/app.dSYM.zip" "$DSYM"
echo "done." >> $LOG
echo "Uploading to TestFlight... " >> $LOG
/usr/bin/curl "http://testflightapp.com/api/builds.json" \
-F file=@"/tmp/app.ipa" \
-F dsym=@"/tmp/app.dSYM.zip" \
-F api_token="$API_TOKEN" \
-F team_token="$TEAM_TOKEN" \
-F replace=True \
-F distribution_lists=Core \
-F notes="Build uploaded automatically from Xcode." >> $LOG
echo >> $LOG
echo "Uploaded to TestFlight!" >> $LOG
/usr/bin/open "https://testflightapp.com/dashboard/builds/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment