Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jsdario/1f88564f412098814043b089404c1865 to your computer and use it in GitHub Desktop.
Save jsdario/1f88564f412098814043b089404c1865 to your computer and use it in GitHub Desktop.
Automated Xcode build and upload to TestFlight.
#!/bin/sh
# Current as working as of 2012/4/17
# Xcode 4.3.2
PROJECT_ROOT="$HOME/SomeDirWhereYourProjectLives/XXXXXXXX"
WORKSPACE="$PROJECT_ROOT/XXXXXXXX.xcodeproj/project.xcworkspace"
CONFIG="AdHoc"
SCHEME="XXXXXXXX"
SDK="iphoneos"
TARGET="XXXXXXXX"
BUILDDIR="$HOME/build$TARGET"
OUTPUTDIR="$BUILDDIR/AdHoc-iphoneos"
APPNAME="XXXXXXXX"
DEVELOPER_NAME="John Doe (PRTG45V3X)"
PROVISIONING_PROFILE="$PROJECT_ROOT/XXXXXXXX.mobileprovision"
echo $BUILDDIR
cd $PROJECT_ROOT
echo "********************"
echo "* Cleaning *"
echo "********************"
xcodebuild -alltargets clean
# echo "********************"
# echo "* Archiving *"
# echo "********************"
# xcodebuild -workspace $WORKSPACE -scheme $SCHEME archive
echo "********************"
echo "* Building *"
echo "********************"
xcodebuild -sdk "$SDK" -target $TARGET -configuration "$CONFIG" OBJROOT=$BUILDDIR SYMROOT=$BUILDDIR
echo "********************"
echo "* Signing *"
echo "********************"
xcrun -log -sdk iphoneos PackageApplication -v "$OUTPUTDIR/$APPNAME.app" -o "$OUTPUTDIR/$APPNAME.ipa" -sign "$DEVELOPER_NAME" -embed "$PROVISIONING_PROFILE"
API_TOKEN="ZZZZZZZZZZZZZZ"
TEAM_TOKEN="YYYYYYYYYYYYYY"
RELEASE_NOTES="TBD"
# remove the old zipped dSYM
rm -rf "$OUTPUTDIR/$APPNAME.app.dSYM.zip"
# zip up the new dSYM, we must cd to where the dSYM is or the zip command will zip up tons of intermediate dirs
cd $OUTPUTDIR
zip -r -9 "$OUTPUTDIR/$APPNAME.app.dSYM.zip" "$APPNAME.app.dSYM"
curl http://testflightapp.com/api/builds.json \
-F file="@$OUTPUTDIR/$APPNAME.ipa" \
-F dsym="@$OUTPUTDIR/$APPNAME.app.dSYM.zip" \
-F api_token="$API_TOKEN" \
-F team_token="$TEAM_TOKEN" \
-F notes="$RELEASE_NOTES" -v
echo "********************"
echo "* Cleaning up *"
echo "********************"
echo $BUILDDIR
rm -Rf "$BUILDDIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment