Sunday 9 December 2012

create IPA file (Xcode 4 , Xcode 4.3)

For Xcode 4 -----

 

 

Note: If you're using Xcode 4.3 or newer, refer to this tutorial instead.


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.



3. Select the newly added Entitlements.plist file and change the Can Be Debugged (get-task-allow) key to NO.



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"



4. 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.



Configure Archive Scheme
1. In the scheme dropdown in the top-right of the IDE, select iOS Device and click Edit Scheme



2. In the scheme editor window, select the "Archive" scheme in the left and change the Build Configuration setting to "Ad Hoc"



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



4. Select iOS App Store Package (.ipa) in Contents and the appropriate Distribution code signing identity in the drop-down


 
  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.


  Xcode 4.3------

With the release of Xcode 4.3, Apple has made it even easier to generate an IPA. However, some of these changes have caused some confusion with some users. This tutorial will walk you through the easiest way to generate an IPA as well as some more advanced configurations. We will be using a sample project which will walkthrough creating the project to IPA generation.

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.


Creating the Basic Application

  1. Choose a template for your new project. For this sample application, we will be creating a Single View Application.
  2. Enter your product name, company identifier, and other configuration options. The product name and company identifier will be combined to generate the Bundle Identifier. This will be used later to determine which provisioning profiles can be used when building and sharing the application.
  3. In the file list on the left side of the window, select your project and your target. On the Summary tab, notice the Bundle Identifer has been generated based on the values entered in step 2.
  4. Scroll down and expand the Entitlements section in the Summary tab. In previous versions of Xcode, you were required to create an Entitlements file and create a get-task-allow key. This is no longer necessary. Unless your application requires special permissions surrounding iCloud or Keychain Access, you are not required to create this file. Leave the Enable Entitlements checkbox unchecked.
  5. Go to the Build Settings tab and scroll down to the Code Signing section. For the two default build configurations (Debug and Release), select your Development Provisioning Profile for Debug and your Ad Hoc Provisioning Profile for Release. Leave Code Signing Entitlements blank.
     
  6. In the dropdown in the top left, select Edit Scheme. You will notice that the default build configurations have already been configured based on the build action being performed. If you are performing a Run action (Product -> Run) to test your application on the iOS Simulator or on your device, your app will be built using the Debug configuration, which in turn signs your app with the Development Provisioning Profile. If you are performing an Archive action (Product -> Archive), your app will be built with the Release configuration, which in turn signs your app with your Distribution Provisioning Profile (either Ad Hoc or App Store).


Generate the IPA

The easiest way to generate an IPA, which can be uploaded to TestFlight, is to archive your applications and share it from the Xcode Organizer.
  1. Change the build target from iPad/iPhone Simulator to iOS Device.
  2. Under the Product menu, select Archive. This will build your application and code sign it using the Distribution (Ad Hoc or App Store) profile setup in step 5 of the “Creating the Basic Application” section. Once the build has completed the Organizer window will appear. If it does not, open it using CMD-Shift–2 or Window -> Organizer. If you see a message popup saying “codesign wants to sign using key ”privateKey“ in your keychain.”, select Allow or Always Allow.
  3. Go to the Archives tab in Organizer and select your application, if it was not automatically selected, and choose the archive you wish to share.
  4. Click the Distribute button. In the next window select “Save for Enterprise or Ad-Hoc Deployment”, and click Next.
  5. In the Code Signing Identity drop down, select the same Distribution Provisioning Profile specified in the Release configuration from step 5 of the “Creating the Basic Application” section, and click Next. NOTE: When generating an IPA for distribution on TestFlight, you should always use an Ad Hoc Distribution Provisioning Profile for both the Archive and Distribute options.
  6. Select where you would like to save your IPA and upload to TestFlight.


Specifying Entitlements


Entitlements allow you to specify specific capabilities or security permissions for your application, such as configuring iCloud. Every application has a default set of values for certain entitlements. By enabling entitlements you are overwriting those default values. In previous versions of Xcode, the most common entitlement set was setting get-task-allow to false. This caused an enormous amount of confusion. In Xcode 4.3 this entitlement is automatically set based on whether the app was built using a Development or Distribution Provisioning Profile. To setup specific entitlements for your application:
  1. Create your application using the same basic setups in the “Creating the Basic Application” section.
  2. Go to the Summary tab for your Target. Check the Enable Entitlements checkbox. This will create a .entitlements file and add it to your project.
  3. You can setup specific iCloud entitlements and Keychain Access Groups for your application as needed.
For more information on specific entitlements, check out the Entitlements documentation on Apple’s developer website. NOTE: if you will be enabling iCloud for your application, you must enable iCloud for your Application ID on the developer portal.

Commonly Asked Questions

Q: Why must I use the same provisioning profile when archiving and generating my IPA?
A: When your application is compiled, information from the provisioning profile used to codesign your application is embedded in the application executable. When you generate your IPA, your application is codesigned again and the provisioning profile used to codesign is added to the IPA as the embedded.mobileprovision file. If there is a mismatch in certain pieces of information between the profile info in the executable and the profile info in the embedded.mobileprovision, this can cause the install to fail.

No comments:

Post a Comment