Wednesday, November 6, 2013

How to resign an IPA with new bundle Id, certificate and entitlements

  1. Create an Entitlements.plist using Xcode
    1. Include the following keys values in the plist file. 
      1. application-identifier (String) -> 3Q83MXXZGH.com.company.appname
      2. get-task-allow (Boolean) -> NO
  2. Put the Entitlements.plist in the same folder of the app.ipa file
  3. Unpackage the app
    1. unzip app.ipa
  4. Delete current code signature
    1. rm -rf Payload/MyApp.app/_CodeSignature/
  5. Open Payload/MyApp.app/Info.plist in Xcode and update the bundle ID(CFBundleIdentifier)
  6. Copy the new .mobileprovision file to Payload/MyApp.app/embedded.mobileprovision
  7. Run the codesign command
    1. codesign -f -s "iPhone Distribution: Company Certificate" --resource-rules Payload/MyApp.app/ResourceRules.plist --entitlements Entitlements.plist Payload/MyApp.app
  8. Repackage the app
    1. zip -qr app-resigned.ipa Payload/
Sample Entitlements.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>application-identifier</key>
 <string>3Q83MXXZGH.com.company.appname</string>
 <key>get-task-allow</key>
 <false/>
</dict>
</plist>

No comments: