Sometimes you will need to run an ipa file created by other developers on your device, in order to do so, you will need to resign the ipa file with your ios developer certificate and profile. The below are steps to do so by assuming the app name is my.app
1. rename ipa file to zip file and unzip it
2. in terminal app, cd into folder which contains zip file
3. run
rm -r "Payload/my.app/_CodeSignature"
to delete current code sign signature. Assume the ipa file name is my.ipa
4. download you signing profile from apple dev website and then use it to replace the one in ipa file
cp "mynewprovisionprofile.mobileprovision" "Payload/my.app/embedded.mobileprovision"
The file name must be changed to embedded.mobileprofile
6. if you want to update any resource files included in the original ipa, like plist file or image resource files, you can do it now.
1. rename ipa file to zip file and unzip it
2. in terminal app, cd into folder which contains zip file
3. run
rm -r "Payload/my.app/_CodeSignature"
to delete current code sign signature. Assume the ipa file name is my.ipa
4. download you signing profile from apple dev website and then use it to replace the one in ipa file
cp "mynewprovisionprofile.mobileprovision" "Payload/my.app/embedded.mobileprovision"
The file name must be changed to embedded.mobileprofile
5. replace appid with your app id specified in your signing profile
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier com.sap.fiori.client.me" ./Payload/my.app/Info.plist
Assume the appid specified in the signing profile is "com.sap.fiori.client.me"
Assume the appid specified in the signing profile is "com.sap.fiori.client.me"
5. copy an entitlement file from your own xcode project that uses the same appid you will sign the ipa file. The entitlement file is in xcode derivedData folder's Build/Intermediates.noindex/YourAppName.build/Debug-iphoneos/YourAppName.app.xcent.
Copy this file to the folder containing the ipa file, and rename it to entitlements.xml for easy to use
6. if you want to update any resource files included in the original ipa, like plist file or image resource files, you can do it now.
7. Resign the content again with the new entitlement and sign cert
/usr/bin/codesign --entitlements entitlements.xml -f -s "iPhone Developer: Haiquan Li (WV2JN948JT)" "./Payload/my.app"
you can get your signing cert name from keychain utility app
you can get your signing cert name from keychain utility app
8. zip the payload folder to get the new ipa file
zip -qr "my.resigned.ipa" Payload
The above steps can also be executed by using the below script.
#!/bin/sh
#To run the script, first copy provision profile embedd.mobileprovision and entitlement.xml to the
#same folder as ipa file is stored
#then run the below command
#sh ThisShellFileFullPath IPAFileFullPath OptionalNewAppID
#for example to resign the ipa using new bundle id of com.sap.fiori.client.me
#bash /Users/i826633/Documents/Jonathan/git826633/tools/IPA\ re-sign/resign.sh /Users/i826633/Documents/Bugs/359459passcode/FioriClient_release-1.11.2-Release-iphoneos.ipa com.sap.fiori.client.me
echo "ios ipa resign"
IPAFilePath="$1"
echo "IPA file path: $IPAFilePath"
IPAFileName=$(basename "$IPAFilePath" ".ipa")
echo "$IPAFileName"
ZipFileName=$IPAFileName".zip"
echo "$ZipFileName"
cp $IPAFilePath $ZipFileName
ZipFileFolder=$IPAFileName"zip"
echo "$ZipFileFolder"
tar xvf $ZipFileName
BundleFileName=$(ls ./Payload)
echo $BundleFileName
BundleName=$(basename "$BundleFileName" ".app")
echo $BundleName
#remove codesignature
rm -r "./Payload/""$BundleFileName""/_CodeSignature"
cp "embedded.mobileprovision" "./Payload/""$BundleFileName""/embedded.mobileprovision"
if [ "$2" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $2" "./Payload/""$BundleFileName""/Info.plist"
else
echo "No App ID needs to be changed"
fi
/usr/bin/codesign --entitlements entitlements.xml -f -s "iPhone Developer: Haiquan Li (WV2JN948JT)" "./Payload/""$BundleFileName"
zip -qr "$BundleFileName"".resigned.ipa" "./Payload"
The above steps can also be executed by using the below script.
#!/bin/sh
#To run the script, first copy provision profile embedd.mobileprovision and entitlement.xml to the
#same folder as ipa file is stored
#then run the below command
#sh ThisShellFileFullPath IPAFileFullPath OptionalNewAppID
#for example to resign the ipa using new bundle id of com.sap.fiori.client.me
#bash /Users/i826633/Documents/Jonathan/git826633/tools/IPA\ re-sign/resign.sh /Users/i826633/Documents/Bugs/359459passcode/FioriClient_release-1.11.2-Release-iphoneos.ipa com.sap.fiori.client.me
echo "ios ipa resign"
IPAFilePath="$1"
echo "IPA file path: $IPAFilePath"
IPAFileName=$(basename "$IPAFilePath" ".ipa")
echo "$IPAFileName"
ZipFileName=$IPAFileName".zip"
echo "$ZipFileName"
cp $IPAFilePath $ZipFileName
ZipFileFolder=$IPAFileName"zip"
echo "$ZipFileFolder"
tar xvf $ZipFileName
BundleFileName=$(ls ./Payload)
echo $BundleFileName
BundleName=$(basename "$BundleFileName" ".app")
echo $BundleName
#remove codesignature
rm -r "./Payload/""$BundleFileName""/_CodeSignature"
cp "embedded.mobileprovision" "./Payload/""$BundleFileName""/embedded.mobileprovision"
if [ "$2" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $2" "./Payload/""$BundleFileName""/Info.plist"
else
echo "No App ID needs to be changed"
fi
/usr/bin/codesign --entitlements entitlements.xml -f -s "iPhone Developer: Haiquan Li (WV2JN948JT)" "./Payload/""$BundleFileName"
zip -qr "$BundleFileName"".resigned.ipa" "./Payload"
No comments:
Post a Comment