A little Bash script for speeding up Ad Hoc iPhone distribution builds

Check out the Ad Hoc Packager script I released that is far better than the old bash script.

When deploying beta builds of your iPhone apps, you make what is known is an Ad Hoc distribution. Apple's instructions tell you that you should zip up the Ad Hoc distribution and send it to your testers along with your .mobileprovision file. As John Hartzog discovered, however, using the Compress option in Finder for Ad Hoc distribution has drawbacks so you should use the command line to package up your Ad Hoc distributions.

John provides a few simple commands that let you do this in his blog post and I've been using this for the beta builds of 'avit but I soon got bored of manually typing these in. So, instead, I wrote up a quick re-usable Bash script, building on John's, that makes packing up an Ad Hoc distribution very easy.

Here's the script:

if [ "$1" == "" ] ; then
echo "Usage: adhoc <NameOfApp>"
echo "Deploying $1…"
mkdir Payload
cp -rp "$1".app Payload/
zip -r "$1".ipa iTunesArtwork Payload
echo "Done! Send your .mobileprovision and $1.ipa file to your beta testers."

Either save the above code in a file called adhoc (and don't forget to chmod +x adhoc) or

Download the script

adhoc.zip (352 bytes)

Usage instructions

  1. Create a folder for your distribution, e.g., "MyApp Beta X"
  2. Download the mobile provisioning file you created in the iPhone Developer Program Portal and make sure that it includes all the Devices you want this build to run on (i.e., the Device IDs of your beta testers' iPhones, iPods, etc.)
  3. Copy the AdHoc script into the "MyApp Beta X" folder
  4. Create a 512x512 PNG or JPEG of your icon, name it iTunesArtwork (without an extension; this is important) and place that in the "MyApp Beta X" folder also.
  5. In XCode, create a new Distribution build of your app, making sure to select the correct mobile provisioning profile in the Code Signing Identity section of your Project Settings.
  6. Under the Products section of the Groups & Files pane in XCode, right-click the name of your app (e.g., MyApp) and select Reveal in Finder. Copy this executable to your "MyApp Beta X" folder also.
  7. Finally, in Terminal, switch to your "MyApp Beta X" folder (tip: you can drag the folder into the Terminal window to get its path)
  8. Type: ./adhoc MyApp, substituting the name of your application's executable with MyApp.
  9. That's it! When the script is done, you will find MyApp.ipa in the "MyApp Beta X"

When distributing your Ad Hoc build, make sure you send both the MyApp.ipa and your .mobileprovision file to your testers.

I hope this little script helps speed up your process.