Tuesday, December 4, 2012

IOS Provisioning

Creating a Developer Certificate

When developer certificate is close to expire or you have provisioning conflicts you may need to have a fresh start. Start with creating a new certificate:

  1. Revoke the old certificate from IOS portal/Certificates
  2. Create a new certificate from Keychain Access on Mac using KeyChainAccess/Certificate Assistant/Request a Certificate From a Certificate Authority menu option and Save to Disk.
  3. From IOS portal/Certificates upload new certificate then Submit. Refresh browser.
  4. Download IOS Development Certificate (ios_development.cer) and run.
Remove the duplicate development certificate

This step is required to fix an error when you build your project in XCode, after installing new certificate:
CodeSign error: Certificate identity 'iPhone Developer: XXXX (12345678)' appears more than once in the keychain. The codesign tool requires there only be one.

Somehow the old developer certificate is cached in XCode and added to KeyChain. To fix this it needs to be removed from KeyChain. The old developer certificate has an earlier expiration date and it is labelled as "iPhone developer..".

  1. Exit XCode
  2. In KeyChain Access under Login KeyChain/My Certificates category remove the old developer certificate starting with "iPhone developer..".
  3. In KeyChain Access under System KeyChain/Certificates category remove the old developer certificate starting with "iPhone developer..".
  4. Start XCode. This may recreate the old certificate again. Repeat steps 2 and 3.
App IDs

On the Provisioning Portal App IDs section enable required entitlements (such as iCloud) for both wildcard XXXXXXXXXX.* and XXXXXXXXXX.com.company.product.* App IDs. Enable all entitlements for simplicity.

Create Provisoning Profiles

On IOS Provisioning Portal delete all provisioning profiles under Provisioning section.

You need to create:

  1. A Development Provisioning Profile for wildcard App ID
  2. An AppStore Distribution Profile for product App ID
  3. An Adhoc Distribution Profile for product App ID
On XCode:
  1. Remove all provisioning profiles under Organizer/Library and Organizer/Device sections.
  2. Under Library/provisioning Profiles click Refresh on the bottom right.
  3. Check that under Organizer/Device required profiles were created. If not drag them from Organizer/Library section.
Setup XCode

On XCode

  1. Create two Schemes "Adhoc" and "App Store" from Product/Edit(New) Scheme.
  2. Set Archive/Build configuration of Adhoc scheme to "Adhoc distribution"
  3. Set Archive/Build Configuration  of App Store scheme to "Release".
  4. On Build Settings/Targets pick Ad Hoc Distribution Profile for  Ad Hoc Distribution Code Signing Identity.
  5. On Build Settings/Targets pick Team Provisioning Profile (generated by XCode) for  Debug Code Signing Identity.
  6. On Build Settings/Targets pick App Store Distribution Profile for  Release Code Signing Identity.
  7. Delete Product.entitlements file.
  8. On Targets/Summary check Entitlements box and fill relevant entitlements. For example if your app uses iCloud, check Enable iCloud checkbox and add your product App ID to Ubiquity Containers section.
  9. Some sections will be filled and created by XCode.
If you complete all above successfully you should be able to Debug your app on a connected device, upload your app in Ad Hoc distribution mode to your device, upload your app to App Store, or run your app on a simulator. 

When you are ready to submit to App Store make sure to pick up the App Store Scheme, then Archive.

References:

Video on certificate creation:


CodeSign error: Certificate identity 'iPhone Developer: XXXX (12345678)' appears more than once in the keychain

iTerm2 - How to auto-close sessions and auto-exit when last one closed

 Problem There are two problems when you close sessions and windows in ITerm2. When you gracefully exit from ITerm2 sessions with a recommen...