Xcode 3.2 provides an awesome new feature under the Build menu, \"Build and Archive\" which generates an .ipa file suitable for Ad Hoc distribution. You can also open the O
We developed an iPad app with XCode 4.2.1 and wanted to integrate the build into our continuous integration (Jenkins) for OTA distribution. Here's the solution I came up with:
# Unlock keychain
security unlock-keychain -p jenkins /Users/jenkins/Library/Keychains/login.keychain
# Build and sign app
xcodebuild -configuration Distribution clean build
# Set variables
APP_PATH="$PWD/build/Distribution-iphoneos/iPadApp.app"
VERSION=`defaults read $APP_PATH/Info CFBundleShortVersionString`
REVISION=`defaults read $APP_PATH/Info CFBundleVersion`
DATE=`date +"%Y%m%d-%H%M%S"`
ITUNES_LINK="Download iPad2-App v$VERSION.$REVISION-$DATE<\/a>"
# Package and verify app
xcrun -sdk iphoneos PackageApplication -v build/Distribution-iphoneos/iPadApp.app -o $PWD/iPadApp-$VERSION.$REVISION-$DATE.ipa
# Create plist
cat iPadApp.plist.template | sed -e "s/\${VERSION}/$VERSION/" -e "s/\${DATE}/$DATE/" -e "s/\${REVISION}/$REVISION/" > iPadApp-$VERSION.$REVISION-$DATE.plist
# Update index.html
curl https://xxx.xxx.xxx/index.html -o index.html.$DATE
cat index.html.$DATE | sed -n '1h;1!H;${;g;s/\(Aktuelle Version<\/h3>\)\(.*\)\(Ältere Versionen<\/h3>..- \)/\1\
${ITUNES_LINK}\
\3\2<\/li>\
- /g;p;}' | sed -e "s/\${ITUNES_LINK}/$ITUNES_LINK/" > index.html
Then Jenkins uploads the ipa, plist and html files to our webserver.
This is the plist template:
items
assets
kind
software-package
url
https://xxx.xxx.xxx/iPadApp-${VERSION}.${REVISION}-${DATE}.ipa
kind
full-size-image
needs-shine
url
https://xxx.xxx.xxx/iPadApp.png
kind
display-image
needs-shine
url
https://xxx.xxx.xxx/iPadApp_sm.png
metadata
bundle-identifier
xxx.xxx.xxx.iPadApp
bundle-version
${VERSION}
kind
software
subtitle
iPad2-App
title
iPadApp
To set this up, you have to import the distribution certificate and provisioning profile into the designated user's keychain.