Wednesday, October 24, 2012

Making a Release Build for Ad-Hoc Distribution of an iOS App


Making a release build for the app store or for distributing an app in your company is always a pain in the neck. Apple insists on changing the process for each version of XCode, changing the rules,  changing licences, once or twice a year. There are numerous articles and blog post on the web that will try to help you build a release version of your app. I say try because it’s hard to find an up-to-date article that will fit your XCode and Mac OS version.
So, this is my contribution to the confusion of articles on making a release build for an iOS App.

On the 29th of August of 2012 with XCode 4.4, Mac OS Lion 10.7.4 and iOS 5 these are the steps on making a release build for Ad-Hoc distribution of an iOS app.


First go to https://developer.apple.com and log in. The page will look like this




Register Devices

The devices to which you intent to install your app need to be registered in your account.

Click on iOS Provisioning Portal


Click on Devices and the on Add Devices


To add a Device you need any name and a Device ID. To get the Device ID you have to

  1. Connect your device to your Mac
  2. Open Itunes
  3. On the summary page
  4. In there you will see the Serial Number of your device
  5. Click on the Serial Number and you will see the Device ID
  6. Click command-c (Mac) or ctrl-c (Windows) to copy it to the clip board. You can then paste it on the iOS Provisioning Portal or send it by email to whoever is registering your device





Give a name to the device and the Device ID and click Submi. You can register up to 100 devices.





Create an App ID


Your app must have an AppID

Click App IDs. On the tab Manage click New App ID.



  1. Write a intuitive name for your App ID in the Description
  2. Select your Team ID. You should have one from your Apple Developer License
  3. The Bundle Identifier must be the same as in your Project. Go to XCode to get it
  4. Submit



Create the Distribution Provisioning Profile


On the same page click on Provisioning on the left, then the Distribution tab and then New Profile button



  1. Select Ad Hoc
  2. Choose a intuitive profile name
  3. Click New Profile button



After submitting the profile it will be available in the profiles page. Once it is active, should take a few seconds (must refresh the page), you can download it.


After downloading the profile you must install it on XCode. You can drag and drop the file to your XCode icon



After this the XCode’s Organizer will open and you can check for the profile




Create the Distribution Archive


Now back to  XCode. Select the Project and the info tab.


In the configuration Table add a new configuration. Click the plus sign to duplicate the Release configuration



Name the new configuration Ad-Hoc. It will look like this at the end.


Now, still in the Project view, go to Build Setting tab.
The Ad-Hoc configuration is in the Code Signing Identity table.
In the row named Ad-Hoc and sub-row named Any iOS SDK click on the AdHocTestApp row to select a profile


And select the profile you created on the Apple Developer Portal


Next, click on the Scheme selection button on the top left


and select Edit Scheme


Select Archive on the left.
Select the Ad-Hoc Build Configuration and click Ok



You are now all set up ( Finally!!! ) to create the distribuition package.

  1. Click on the Scheme selection button and select iOS Device
  2. Build you App
  3. After it finishes select Archive


The Organizer window will open after the archiving finishes

Now click on Distribute

Select Save for Enterprise or Ad-Hoc Deployment


On the next window choose your Ad-Hoc profile and click next.




Select where you want to save the .ipa package, I chose the desktop.


At this point you have two choices regarding Save for Enterprise Distribution check box

  1. Install the app through iTunes. Leave it uncheked
  2. Download and Install the app on the iPhone through a webpage.  Check it.

If you choose the first option the file AdHocTestApp.ipa will be created on the desktop and you can now drag and drop it to you iTunes and then synchronize the app. The Profile you created is embedded in .ipa package. And you're done! Congratulations!!


Or not... If you choose the second option there are still a few more steps. So keep reading.

  1. Choose a name for the package
  2. Check the Save for Enterprise Distribution option
  3. Type the URL of the location of the .ipa in your server
  4. Add a title

I haven’t tested the subtitle and image URLs yet.

Click save.

This will generate two files in your desktop

  • AdHocTestApp.ipa
  • AdHocTestApp.plist

You have to copy this files to your server to the location you specified above


The next step will be creating a web page form which you can donwload the app. This is the simplified version.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>AdHoc Test App</title>
</head>
<body>
  <ul>
<li>
<a href="itms-services://?action=download-manifest&
Tap here to install AdHocTestApp
</a>
  </li>
  </ul>
</body>
</html>

Notice that the href link is not the .ipa but .plist


You are all done!

note: in my case I am using an Microsoft server and I had to add the corresponding MIME Types for the .ipa and .plist. (no screen shots, sorry)

  1. Go to IIS Manager
  2. Locate you web site folder
  3. Right click and select Properties
  4. Open HTTP Headers tab
  5. Click on MIME Types button at the bottom
  6. Click New... button and add these two
    1. .ipa application/octet-stream
    2. .plist text/xml

Now, on your device, navigate to the page and download and install the app.

          


Good Luck!!