Skip to content

Instantly share code, notes, and snippets.

@4c00h
Last active August 29, 2015 14:19
Show Gist options
  • Save 4c00h/fa812fe543680b967c47 to your computer and use it in GitHub Desktop.
Save 4c00h/fa812fe543680b967c47 to your computer and use it in GitHub Desktop.
#!/bin/bash
#name of ipa file
IPA=""
#path to .mobileprovision
PROVISION=""
#certificate name as appears in the keychain e.g. "iPHONE Distribution: Example "
CERTIFICATE=""
#bundle identifier e.g. com.yourcompany.app
BUNDLE_ID=""
###########
unzip -q "$IPA"
# remove the signature
rm -rf Payload/*.app/_CodeSignature Payload/*.app/CodeResources
# extract plist from .mobileprovision file
security cms -D -i "$PROVISION" > ProvisionProfile.plist 2>&1
# extract entitilements.plist from plist
/usr/libexec/PlistBuddy -x -c "Print Entitlements" ProvisionProfile.plist > Entitlements.plist 2>&1
# replace the provision
cp "$PROVISION" Payload/*.app/embedded.mobileprovision
#Modify bundle identifier in Info.plist as shown in apple developer center (e.g. com.yourcompany.app).
$(/usr/libexec/PlistBuddy -x -c 'Set :CFBundleIdentifier '$BUNDLE_ID'' Payload/elevation.app/Info.plist
# Verify bundle_id changed correctly
$(/usr/libexec/PlistBuddy -x -c 'Print :CFBundleIdentifier' Payload/elevation.app/Info.plist )
# sign with the new certificate
codesign -f -s "$CERTIFICATE" --entitlements Entitlements.plist Payload/*.app
zip -qr resigned.ipa Payload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment