Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Xcode Build OTA
#!/bin/sh
# This script was written by Jay Graves for the 360iDev Conference.
# You can find the full slides available at http://skabber.com/
# This script requires Xcode and s3cmd http://s3tools.org/s3cmd
# You will need your own Amazon S3 account to upload files.
# Put your distribution certificates and keys in the System Keychain
# otherwise you will need to use security unlock-keychain
TARGET=GroupA
PlistBuddy=/usr/libexec/PlistBuddy
S3CMD=/usr/local/bin/s3cmd
S3BUCKET=skabber-public
# Clean
xcodebuild clean
git clean -fdx
# Compile the .app
xcodebuild -target $TARGET -configuration AdHoc
# Create the .ipa
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "Release-iphoneos/${TARGET}.app" -o "./${TARGET}.ipa" --sign "Massively Overrated" --embed $HOME/Library/MobileDevice/Provisioning\ Profiles/Group_A_Ad_Hoc.mobileprovision
# Create the .plist
PLISTFILE=$TARGET.plist
APPTITLE=GroupA
IPAURL=http://$S3BUCKET.s3.amazonaws.com/$TARGET.ipa
ICONURL=http://$S3BUCKET.s3.amazonaws.com/icon@2x.png
BUNDLEVERSION=1.0
BUNDLEID=com.massivelyoverrated.groupa
$PlistBuddy -c "Add :items array" $PLISTFILE
$PlistBuddy -c "Add :items:0 dict" $PLISTFILE
$PlistBuddy -c "Add :items:0:assets array" $PLISTFILE
# App Icon
$PlistBuddy -c "Add :items:0:assets:0 dict" $PLISTFILE
$PlistBuddy -c "Add :items:0:assets:0:kind string display-image" $PLISTFILE
$PlistBuddy -c "Add :items:0:assets:0:needs-shine bool NO" $PLISTFILE
$PlistBuddy -c "Add :items:0:assets:0:url string \"$ICONURL\"" $PLISTFILE
# App IPA
$PlistBuddy -c "Add :items:0:assets:1 dict" $PLISTFILE
$PlistBuddy -c "Add :items:0:assets:1:url string \"$IPAURL\"" $PLISTFILE
$PlistBuddy -c "Add :items:0:assets:1:kind string software-package" $PLISTFILE
# Meta Data
$PlistBuddy -c "Add :items:0:metadata dict" $PLISTFILE
$PlistBuddy -c "Add :items:0:metadata:title string \"$APPTITLE\"" $PLISTFILE
$PlistBuddy -c "Add :items:0:metadata:kind string software" $PLISTFILE
$PlistBuddy -c "Add :items:0:metadata:bundle-version string $BUNDLEVERSION" $PLISTFILE
$PlistBuddy -c "Add :items:0:metadata:bundle-identifier string $BUNDLEID" $PLISTFILE
# Upload the files to S3
$S3CMD --acl-public put $TARGET.ipa s3://$S3BUCKET/
$S3CMD --acl-public put $TARGET.plist s3://$S3BUCKET/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment