Xcode 4 - Command line builds of iPhone apps
Here’s the gist of how you can build your iPhone app from the command line. Change into the folder that contains your *.xcodeproj, and run the following:
xcodebuild -target "My Target" -scheme "My Scheme" -configuration Release clean archive
This will generate an xcode archive (*.xcarchive) in ~/Library/Developer/Xcode/Archives/DATE/… somewhere.
Now you’ve got your xcarchive, and assuming that your project was set up to sign using an ad-hoc provisioning profile, how to generate the IPA file that you can submit to TestFlight for your testers?
/usr/bin/xcrun -sdk iphoneos PackageApplication "/absolute/path/to/MyApp.xcarchive/Products/Applications/MyApp.app" -o "/absolute/path/to/MyApp.ipa"
Note that PackageApplication somehow only works if you use absolute paths. So ~ and relative paths don’t work – beware of that.
Now, if you’re clever, you can script all this with ruby to be nicely automated. I’ll get into that in another post. This is part one of a series on continuous integration of iOS apps that i’m working on…