2011年11月3日星期四

How to create an IPA (Xcode 4)

How to create an IPA (Xcode 4):
With the release of Xcode 4, there have been a lot of issues with people being unable to package their applications as IPAs. The new version of Xcode, while making a lot of tasks easier and more streamlined, has caused some confusion due to some internal changes that have not been terribly well documented. In this tutorial we will walk you through setting up your project so you can create an ad hoc IPA suitable for beta distribution. Thanks as well to @nkostelnik for his recent tutorial on this topic.
NOTE: this tutorial only covers how to configure your project in order to package the application as an IPA. It does not cover how to create or migrate a project with or without 3rd party libraries.
Create Entitlements
1. Go to File -> New -> New File.
2. Under Code Signing, select Entitlements. Leave the filename as Entitlements.plist.
tf_x4_entitlements.png3. Select the newly added Entitlements.plist file and change the Can Be Debugged (get-task-allow) key to NO.
tf_x4_get_task.png
There has been a lot of debate as to whether this key needs to be set to NO as a lot of people have stated that their ad hocs work fine with it set to YES. We aim to stay inline with Apple's documentation for creating ad hocs and their most recent documentation on the Developer Portal states that this value should be NO. We would encourage developers to stay consistent with Apple's workflow should they decide to make internal changes in future OS or IDE releases.
Setup the project for Ad Hoc Distribution
1. In the left panel, select your project
2. Under the PROJECT section, select your project to open up the project settings
3. Under configurations, click the + button and select "Duplicate "Release" Configuration". Name the new configuration "Ad Hoc"
tf_x4_create_config.png4. Under the TARGETS section, select your application target
5. Go to Build Settings and ensure the "All" option is selected
6. Under "Code Signing" select the "Code Signing Entitlements" key and click the expand arrow to reveal the per-configuration options
7. In the "Ad Hoc" configuration, enter Entitlements.plist. If you named your Entitlements file something else, enter than name instead.
tf_x4_code_signing.png
Configure Archive Scheme
1. In the scheme dropdown in the top-right of the IDE, select iOS Device and click Edit Scheme
tf_x4_scheme_dropdown.png
2. In the scheme editor window, select the "Archive" scheme in the left and change the Build Configuration setting to "Ad Hoc"
tf_x4_archive_scheme.png
Archiving and Packaging
1. Select the iOS Device option in the Schemes drop-down
2. Under the Product menu, select Archive
3. In the Organizer window that appears (go to Window -> Organizer if it does not), select Archives at the top, your application on the left, and the most recent archive at the bottom, and click Share
tf_x4_organizer.png
4. Select iOS App Store Package (.ipa) in Contents and the appropriate Distribution code signing identity in the drop-down
tf_x4_package.png
  1. Click Next and enter the name of your IPA to save it
  2. Upload your application to TestFlight
Setup build settings for 3rd party libraries
If you are migrating from Xcode 3, or are using cross-project referenced to build 3rd party libraries, and do not get the option to package your app as an IPA when sharing, you may need to modify some of their build settings. This is the biggest holdup for a lot of developers as this was not needed in Xcode 3. This tutorial assumes you are using cross-project references to build your libraries. In the project settings for each 3rd party project, ensure that the Skip Install value is set to YES, otherwise when you attempt to create an IPA you will only get the option to create an .xcarchive file.
Note
If you are migrating from Xcode3, most of the build configurations, schemes, etc. will migrate as well.


Method 2

Distribute Ad Hoc Applications Over the Air (OTA)


If you’ve been through the distribution process of an Ad Hoc application, you can appreciate the challenges of getting a build installed on someone’s device. From the differences of working with users on Windows versus Mac machines, to explaining how to import an Ad Hoc provisioning file and the associated build into iTunes, this process is anything but a walk in the park.
In this post I’ll take you through the steps of deploying Ad Hoc builds over-the-air, where users simply point the Safari web-browser (on their iPhone) to a link and tap to install the provisioning file and associated application.
Provisioning Profile
To begin, create a provisioning profile like you would for any other Ad Hoc build. In the image below you’ll notice I created a profile named AdHocOTAProfile and associated this with the app id AdHocOTA.
How to create an IPA (Xcode 4) - 独步夜雨 - Hello Mobile
Once the profile is created, download onto your location machine and drag/drop the file onto the Xcode icon, this will install the provisioning file into the following folder: ~/Library/MobileDevice/Provisioning Profiles. The image below is a screenshot of the profile path on my machine – notice the provisioning file name is no longer the nice readable name that was written to your file system when you downloaded the file, this is to be expected.
How to create an IPA (Xcode 4) - 独步夜雨 - Hello Mobile
From within Xcode, you can now associate this provisioning profile with your build. In the Target settings, select the Build tab, in the Code Signing section choose the new Provisioning Profile you created:
How to create an IPA (Xcode 4) - 独步夜雨 - Hello Mobile
Xcode Build and Archive
Once you have a working project within Xcode (with the Code Signing identity set as mentioned above), make sure that you set the build type to Device.
How to create an IPA (Xcode 4) - 独步夜雨 - Hello Mobile
From the Build menu in Xcode, choose Build and Archive (if this option is not highlighted, make sure you’ve selected Device in the build settings.
How to create an IPA (Xcode 4) - 独步夜雨 - Hello Mobile
Once the build is complete, the Organizer window will appear – make sure the Archived Applicationssection is selected on the left panel.
How to create an IPA (Xcode 4) - 独步夜雨 - Hello Mobile
In the figure above, I’ve updated the Name of the app to AdHoc OTA Test, this is optional, as well as any comments you would like to include.
Click on the Share button, and a new dialog will appear similar to that shown below:
How to create an IPA (Xcode 4) - 独步夜雨 - Hello Mobile
From the Identity dropdown, select the Provisioning Profile created earlier:
How to create an IPA (Xcode 4) - 独步夜雨 - Hello Mobile
Now choose Distribute for Enterprise – fill in the URL to the location where you plan to host the application. Note that you must include the fullpath to the application, including the name of the .ipa file that you plan to use:
How to create an IPA (Xcode 4) - 独步夜雨 - Hello Mobile
At this point, don’t worry about the image files, I believe those are applicable only if you are doing an OTA deployment through an Enterprise developer account (internal app distribution for corporations). Update: Seems there may be a little more to how the images are used beyond Enterprise deployments, see the comments section for more information.
Once you select Ok, you will be prompted for a filename to save the build, verify that you use the same name as you specified in the URL:
How to create an IPA (Xcode 4) - 独步夜雨 - Hello Mobile
At this point ipa and plist files will be created for you, the provisioning file will be embedded within the ipa.
OTA HTML File
With the build complete, we know need to create a very simple webpage that will allow users to find the application on a web-server.
The html below is as about as bare-bones as we can get, it’s nothing more than a link to the file, with a specific href for itms-services which Safari will recognize and initiate the download/install process when clicked.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  <html> <head>    <title>OTA Test App</title>  </head>  <body>   <ul>     <li><a href="itms-services://?action=download-manifest&url=http://3SixtySoftware.com/OTAtest/AdHocOTATest.plist"> Tap Here to Install the Application</a>   </li>    </ul>  </body> </html>
Important: – Replace the path shown above with the path to where you will upload the ipa and plist files that Xcode created.
Save the html file with the extension .html
Upload To Web-Server
We’re getting close – at this point we are ready to upload the ipa, plist and html files. The figure below shows the directory listing on the web-server where I uploaded the files:
How to create an IPA (Xcode 4) - 独步夜雨 - Hello Mobile
Install the iPhone Application OTA
To download the application via OTA, start your web-browser and point it to the link where the html file lives. Once loaded you should see a screen similar to the figure below:
How to create an IPA (Xcode 4) - 独步夜雨 - Hello Mobile
Tap on the link and a dialog will appear asking if you would like to install the Ad Hoc application:
How to create an IPA (Xcode 4) - 独步夜雨 - Hello Mobile
If all works as expected, at this point you can send a link to the html file to anyone you included in the provisioning file and they can install the application OTA.

没有评论:

发表评论