Last active
May 23, 2022 21:25
-
-
Save chrismaddern/c3c87bdce8cdefe6752d14ffd0ace01a to your computer and use it in GitHub Desktop.
Re-sign an iOS App with your own Certificate & Provisioning Profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script assumes it's running in a folder with all these files | |
IPA="ipa_to_resign.ipa" | |
PROVISION="my_enterprise_provision_profile.mobileprovision" | |
CERTIFICATE="iPhone Distribution: My Organization, Inc." # must be in keychain | |
# Unzip the IPA & delete existing codesigning | |
unzip -q "$IPA" | |
rm -rf Payload/*.app/_CodeSignature Payload/*.app/CodeResources | |
# Copy the new Provision Profile | |
cp "$PROVISION" Payload/*.app/embedded.mobileprovision | |
# First Sign any resources that need signing | |
cd Payload/*.app/Frameworks | |
for fw in * ; do | |
arr=(`echo $fw | tr '.' ' '`) | |
if [ "${arr[1]}" = "framework" ] | |
then | |
# Framework: Remove the signature & recreate | |
echo "Code Signing Framework: ${fw}/${arr[0]}" | |
rm -rf $fw/_CodeSignature | |
/usr/bin/codesign -v -f -s "$CERTIFICATE" ${fw}/${arr[0]} | |
else | |
# Dylib: Just resign the dylib | |
echo "Code Signing Dylib: ${fw}" | |
/usr/bin/codesign -v -f -s "$CERTIFICATE" ${fw} | |
fi | |
done | |
cd ../../.. | |
# Sign the resulting Payload | |
/usr/bin/codesign -v -f -s "$CERTIFICATE" --entitlements entitlements.plist Payload/*.app | |
# Create the new IPA | |
zip -qr resigned.ipa Payload | |
# Delete intermediate files | |
rm -rf Payload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment