The problem:
Create "Entitlements.plist":
If you have many versions of Xcode, then you'll need to specify a version that contains "codesign_allocate".
References:
- To re-sign a .ipa file with a different distribution provisioning profile.
- To change the bundle identifier.
Required files:
- The .ipa file.
- The distribution provisioning profile. (.mobileprovision)
- Entitlements.plist
Put all the files under the same directory.
Create "Entitlements.plist":
Copy the following code in a text file and make sure that the extension is (.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>kjhdfsui.com.your.bundle.id</string>
<key>get-task-allow</key>
<false/>
</dict>
</plist>
To get the bundle-id value used in "Entitlements.plist" (the previous piece of code), open (.mobileprovision) using an editor and copy the value under "Entitlements".
Re-sign:
- Unzip the .ipa file. in the terminal type
unzip MyApp.ipa
- Inside the (Payload) folder, you'll find the .app file. Open it by right click > show package content.
- find the (info.plist) file and open it using Xcode. replace the old bundle identifier with the new one.
- Open the terminal and move to the directory that contains the (.ipa) file.
- Remove the old code signature
rm -r "Payload/MyApp.app/_CodeSignature" "Payload/MyApp.app/CodeResources" 2> /dev/null | true
- Replace the embedded mobile provisioning profile
cp "MyEnterprise.mobileprovision" "Payload/MyApp.app/embedded.mobileprovision"
- Re-sign
/usr/bin/codesign -f -s "iPhone Distribution: Certificate Name" --resource-rules "Payload/MyApp.app/ResourceRules.plist" --entitlements Entitlements.plist "Payload/MyApp.app"
- Re-package
zip -qr "MyApp.resigned.ipa" Payload
- To submit the app:
- Create an app in itunes connect.
- Use "Application loader" to upload the app.
For some reason you may face this error "Codesign object file format invalid or unsuitable" in step #7. to solve it, type the following in the terminal:
export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"
If you have many versions of Xcode, then you'll need to specify a version that contains "codesign_allocate".
References:
- http://stackoverflow.com/questions/6181813/very-tricky-question-about-iphone-ipad-resigned-builds-behaviors
- http://stackoverflow.com/questions/4842717/iphone-codesign-object-file-format-invalid-or-unsuitable
- http://stackoverflow.com/questions/15634188/resigning-an-ios-provisioning-profile
- http://stackoverflow.com/questions/6896029/re-sign-ipa-iphone
That's it, don't hesitate to comment, to share your knowledge and to correct me.
Re-sign a .IPA file