Skip to content

Instantly share code, notes, and snippets.

@du-song
Created January 24, 2012 11:13
Show Gist options
  • Save du-song/1669673 to your computer and use it in GitHub Desktop.
Save du-song/1669673 to your computer and use it in GitHub Desktop.
Sign IPA with installed Apple developer license
#!/bin/sh
#
# detail in blog post: http://blog.rollingcode.org/2010/07/28/sign-ipa-with-installed-developer-license/
#
SAVEDIR=`pwd`
WORKDIR=/tmp/ipa_$RANDOM$RANDOM
WORKIPA=/tmp/ipa_$RANDOM$RANDOM.ipa
echo Unpacking $1 to $WORKDIR
mkdir -p $WORKDIR
unzip "$1" -d $WORKDIR > /dev/null || exit
cd $WORKDIR
f=`ls -1 Payload | tail -n 1`
echo Processing $f
rm -rf "Payload/$f/_CodeSignature"
cat >"Payload/$f/ResourceRules.plist" <<XXX
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>rules</key>
<dict>
<key>.*</key>
<true/>
<key>Info.plist</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>ResourceRules.plist</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>100</real>
</dict>
</dict>
</dict>
</plist>
XXX
PP=`ls -1 ~/Library/MobileDevice/Provisioning\ Profiles | tail -n 1`
echo Loading Provisioning Profile: $PP
AID=`strings ~/Library/MobileDevice/Provisioning\ Profiles/$PP | grep -A2 ApplicationIdentifierPrefix | tail -n 1 | awk -F '>|<' '{print $3}'`.`defaults read $WORKDIR/Payload/$f/Info.plist CFBundleIdentifier`
echo Entitlement as $AID
cat >"Entitlements.plist" <<XXX
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>application-identifier</key>
<string>$AID</string>
<key>keychain-access-groups</key>
<array>
<string>$AID</string>
</array>
</dict>
</plist>
XXX
codesign -f -s "iPhone Developer" --entitlements Entitlements.plist -vvv "Payload/$f"
echo Repacking
zip -9yr "$WORKIPA" * > /dev/null
cd "$SAVEDIR" && mv "$1" "$1.$RANDOM$RANDOM.bak" && mv "$WORKIPA" "$1" && rm -rf "$WORKDIR"
@feuvan
Copy link

feuvan commented Jan 31, 2012

would be better if incorporate with ipa build script. http://blog.octo.com/en/automating-over-the-air-deployment-for-iphone/

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