#!/bin/bash set -e if [ "$#" -lt 2 ]; then echo "Usage: ./sign_ipa game.ipa profile.mobileprovision certificate" exit fi IPA="$1" PROVISION="$2" ENTITLEMENTS="$3" CERTIFICATE="$4" # must be in keychain # unzip the ipa unzip -qo "$IPA" # remove the signature rm -rf Payload/*.app/_CodeSignature Payload/*.app/CodeResources # replace the provision cp "$PROVISION" Payload/*.app/embedded.mobileprovision # sign with the new certificate /usr/bin/codesign -f -s "$CERTIFICATE" --entitlements $ENTITLEMENTS Payload/*.app # zip it back up OUT=$(dirname "$IPA")/$(basename $IPA .ipa)_$(basename $PROVISION .mobileprovision).ipa zip -qr $OUT Payload #clean up rm -Rf Payload