-
-
Save incanus/1186990 to your computer and use it in GitHub Desktop.
#!/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/" |
I found it useful to leaving the logging on, and to add >> $LOG to the curl and code sign steps, which is where most of my configuration issues surfaced.
And if you want to automatically post the build to your team, add these to the curl command:
-F notify=True -F distribution_lists='<Your TestFlight Distribution List>'
Hi there, thanks for writing this.
Last week I borrowed it and rewrote parts of it to add a bunch of options and a bit of "UI" using AppleScript dialogs:
https://github.com/noodlewerk/NWTestFlightUploader
Cheers.
I've been using this script, and it works great.
Now I've upgraded to Xcode 5 and Xcode Server (Mavericks). No problem there. But when I archive the scheme via a Bot on the server, the script fails because the intermediate products are located in a different location.
I'm curious if there's a way to refactor the script to accomodate running in both the desktop and the server environments.
Here're some of the logs from around the time the script is running:
Touch /Library/Server/Xcode/Data/BotRuns/Cache/d2ff825a-458a-451e-9478-ab9638b90e2e/DerivedData/ArchiveIntermediates/MyApp\ -\ In\ House\ +\ TestFlight/BuildProductsPath/Distribution\ -\ In\ House-iphoneos/MyApp.app.dSYM
cd /Library/Server/Xcode/Data/BotRuns/Cache/d2ff825a-458a-451e-9478-ab9638b90e2e/source/
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/usr/bin/touch -c /Library/Server/Xcode/Data/BotRuns/Cache/d2ff825a-458a-451e-9478-ab9638b90e2e/DerivedData/ArchiveIntermediates/MyApp\ -\ In\ House\ +\ TestFlight/BuildProductsPath/Distribution\ -\ In\ House-iphoneos/MyApp.app.dSYM
ls: /var/teamsserver/Library/Developer/Xcode/Archives/2013-10-10: No such file or directory
LSOpenURLsWithRole() failed for the application /Applications/Utilities/Console.app with error -10810 for the file /tmp/testflight.log.
rm: /tmp/MyApp.ipa: No such file or directory
error: Specified application doesn't exist or isn't a bundle directory : '/var/teamsserver/Library/Developer/Xcode/Archives/2013-10-10//Products/Applications/MyApp.app'
rm: /tmp/MyApp.dSYM.zip: No such file or directory
zip warning: name not matched: /var/teamsserver/Library/Developer/Xcode/Archives/2013-10-10//dSYMs/MyApp.app.dSYM
zip error: Nothing to do! (try: zip -r /tmp/MyApp.dSYM.zip . -i /var/teamsserver/Library/Developer/Xcode/Archives/2013-10-10//dSYMs/MyApp.app.dSYM)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (26) couldn't open file "/tmp/MyApp.ipa"
** ARCHIVE SUCCEEDED **
Here's a link to a similar script, that works via Bots (bot not locally):
https://devforums.apple.com/message/905330
Works like a charm. Thanks
@skela, thanks for that. I've corrected. I hadn't actually tried the
.dSYM
part yet, and caught your fix before I tried it for the first time :-)