Skip to content

Instantly share code, notes, and snippets.

@idy
Created December 9, 2014 06:56
Show Gist options
  • Save idy/8e7072afdb70f3e94e87 to your computer and use it in GitHub Desktop.
Save idy/8e7072afdb70f3e94e87 to your computer and use it in GitHub Desktop.
Use codesign re-sign swift app
#!/bin/sh
# Usage: ./sign.sh INPUT.ipa OUTPUT PROVISION.mobileprovision IDENTITY_NAME ENTITLEMENTS
# Reading parameters
INPUT=$1
OUTPUT=$2.ipa
MOBILE_PROVISTION=$3
CER_NAME=$4
# ENTITLEMENTS=$5
# Cleaning working env
rm -r Payload SwiftSupport
# Unpackaging app
unzip -q $INPUT
APP=`ls Payload | tail -1`
# Replacing mobile provision
echo "Deleting original embedded.mobileprovision"
rm "Payload/$APP/embedded.mobileprovision"
echo "Copying embedded.mobileprovision"
cp "$MOBILE_PROVISTION" "Payload/$APP/embedded.mobileprovision"
# Resigning ipa
echo "Re-sign by $CER_NAME"
# Resigning dylibs
if [ -e Payload/$APP/Frameworks ]
then
for dylib in "Payload/$APP/Frameworks/*"
do
codesign -f -s "$CER_NAME" $dylib
done
fi
# Resigning app
codesign -f -s "$CER_NAME" "Payload/$APP"
# Cleaning output env
rm -r "$OUTPUT"
# Packaging ipa
echo "Packaging ipa"
zip -qr "$OUTPUT" Payload
echo "Re-signed ipa $OUTPUT"
@mluton
Copy link

mluton commented Nov 12, 2015

Thank you! After a couple of modifications this worked for my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment