Skip to content

Instantly share code, notes, and snippets.

@incanus
Created September 1, 2011 19:12
Show Gist options
  • Save incanus/1186990 to your computer and use it in GitHub Desktop.
Save incanus/1186990 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
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
API_TOKEN=<TestFlight API token here>
TEAM_TOKEN=<TestFlight team token here>
SIGNING_IDENTITY="iPhone Distribution: Development Seed"
PROVISIONING_PROFILE="${HOME}/Library/MobileDevice/Provisioning Profiles/MapBox Ad Hoc.mobileprovision"
#LOG="/tmp/testflight.log"
GROWL="${HOME}/bin/growlnotify -a Xcode -w"
DATE=$( /bin/date +"%Y-%m-%d" )
ARCHIVE=$( /bin/ls -t "${HOME}/Library/Developer/Xcode/Archives/${DATE}" | /usr/bin/grep xcarchive | /usr/bin/sed -n 1p )
DSYM="${HOME}/Library/Developer/Xcode/Archives/${DATE}/${ARCHIVE}/dSYMs/${PRODUCT_NAME}.app.dSYM"
APP="${HOME}/Library/Developer/Xcode/Archives/${DATE}/${ARCHIVE}/Products/Applications/${PRODUCT_NAME}.app"
#/usr/bin/open -a /Applications/Utilities/Console.app $LOG
#echo -n "Creating .ipa for ${PRODUCT_NAME}... " > $LOG
echo "Creating .ipa for ${PRODUCT_NAME}" | ${GROWL}
/bin/rm "/tmp/${PRODUCT_NAME}.ipa"
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${APP}" -o "/tmp/${PRODUCT_NAME}.ipa" --sign "${SIGNING_IDENTITY}" --embed "${PROVISIONING_PROFILE}"
#echo "done." >> $LOG
echo "Created .ipa for ${PRODUCT_NAME}" | ${GROWL}
#echo -n "Zipping .dSYM for ${PRODUCT_NAME}..." >> $LOG
echo "Zipping .dSYM for ${PRODUCT_NAME}" | ${GROWL}
/bin/rm "/tmp/${PRODUCT_NAME}.dSYM.zip"
/usr/bin/zip -r "/tmp/${PRODUCT_NAME}.dSYM.zip" "${DSYM}"
#echo "done." >> $LOG
echo "Created .dSYM for ${PRODUCT_NAME}" | ${GROWL}
#echo -n "Uploading to TestFlight... " >> $LOG
echo "Uploading to TestFlight" | ${GROWL}
/usr/bin/curl "http://testflightapp.com/api/builds.json" \
-F file=@"/tmp/${PRODUCT_NAME}.ipa" \
-F dsym=@"/tmp/${PRODUCT_NAME}.dSYM.zip" \
-F api_token="${API_TOKEN}" \
-F team_token="${TEAM_TOKEN}" \
-F notes="Build uploaded automatically from Xcode."
#echo "done." >> $LOG
echo "Uploaded to TestFlight" | ${GROWL} -s && /usr/bin/open "https://testflightapp.com/dashboard/builds/"
@viveknavadia
Copy link

Works like a charm. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment