From 0dbc2cf22daccd044fdceeb1e167649814ddc601 Mon Sep 17 00:00:00 2001 From: Giovanni Di Grezia Date: Sun, 18 Dec 2016 23:59:53 +0000 Subject: [PATCH] Fixed Custom BundleID modification. Replacing the bundleid also of internal apps when using a custom bundle id --- README.md | 9 ++++++++- sign.sh | 10 ++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1a84f4f..c7c539b 100644 --- a/README.md +++ b/README.md @@ -35,4 +35,11 @@ make sure that ipasourcefolder and ipadestfolder are writable. run signall.sh via terminal. done. -In your destination folder you will have all your ipas signed. \ No newline at end of file +In your destination folder you will have all your ipas signed. + + +Additional notes +To change bundleid replace null.null inside the signall.sh script with your custom bundleid. +Restore to null.null to use bundleid included in the ipa. +Using a custom bundleid, if the ipa includes additional apps (for example widget and apple watch), the script will automatically change these bundleids using the following convention : custombundleid.extra1, custombundleid.extra2 and so on. +If you want to change a bundleid for a particular ipa, use only that ipa in the source folder otherwise all ipas present in the source folder will be signed using the same bundleid. \ No newline at end of file diff --git a/sign.sh b/sign.sh index 1d235cd..1a811e4 100644 --- a/sign.sh +++ b/sign.sh @@ -13,7 +13,7 @@ cp "$MOBILEPROV" "extracted/Payload/$APPLICATION/embedded.mobileprovision" echo "Resigning with certificate: $DEVELOPER" find -d extracted \( -name "*.app" -o -name "*.appex" -o -name "*.framework" -o -name "*.dylib" \) > directories.txt -if [ "$BUNDLE" != 'null.null' ]; then +if [[ "$BUNDLE" != 'null.null' ]]; then echo "Changing BundleID with : $BUNDLE" /usr/libexec/PlistBuddy -c "Set:CFBundleIdentifier $BUNDLE" "extracted/Payload/$APPLICATION/Info.plist" fi @@ -21,10 +21,16 @@ security cms -D -i "extracted/Payload/$APPLICATION/embedded.mobileprovision" > t /usr/libexec/PlistBuddy -x -c 'Print:Entitlements' t_entitlements_full.plist > t_entitlements.plist #/usr/libexec/PlistBuddy -c 'Print:application-identifier' t_entitlements.plist > t_entitlements_application-identifier #save developer application-identifier to file #/usr/libexec/PlistBuddy -c 'Print:com.apple.developer.team-identifier' t_entitlements.plist > t_entitlements_com.apple.developer.team-identifier #save com.apple.developer.team-identifier application-identifier to file +var=$((0)) while IFS='' read -r line || [[ -n "$line" ]]; do #/usr/bin/codesign -d --entitlements :- "$line" > t_entitlements_original.plist #save original entitlements from the app #/usr/libexec/PlistBuddy -x -c 'Import application-identifier t_entitlements_application-identifier' t_entitlements_original.plist #overwrite application-identifier #/usr/libexec/PlistBuddy -x -c 'Import com.apple.developer.team-identifier t_entitlements_com.apple.developer.team-identifier' t_entitlements_original.plist #overwrite com.apple.developer.team-identifier + if [[ "$BUNDLE" != 'null.null' ]] && [[ "$line" == *".appex"* ]]; then + echo "Changing .appex BundleID with : $BUNDLE.extra$var" + /usr/libexec/PlistBuddy -c "Set:CFBundleIdentifier $BUNDLE.extra$var" "$line/Info.plist" + var=$((var+1)) + fi /usr/bin/codesign --continue -f -s "$DEVELOPER" --entitlements "t_entitlements.plist" "$line" done < directories.txt @@ -40,4 +46,4 @@ rm t_entitlements.plist rm t_entitlements_full.plist #rm t_entitlements_original.plist #rm t_entitlements_application-identifier -#rm t_entitlements_com.apple.developer.team-identifier \ No newline at end of file +#rm t_entitlements_com.apple.developer.team-identifier