Resigning an application outside xcode

Ompah picture Ompah · Jul 4, 2011 · Viewed 13.5k times · Source

I have some apps i wanna resign with a different apple developer license,

Problem is, i dont have source code, only the ipa file, the app and the archiveinfo.plist is it possible for me to resign the app if i dont have the source code?

Thanks! Ompah

Answer

Reid Rankin picture Reid Rankin · Jul 13, 2011

The ability to replace the signature on an already-signed binary is built into the codesign utility. That way, if your developer certificate expires (as they do annoyingly often), you don't have to rebuild your app.

This can be important, especially if you need to support an old app version, and you've made code alterations since you archived your IPA.

I usually use this script. It comes in handy when trading debug build IPAs with people who have their own developer accounts and who I don't want to burn a UDID slot for, and who don't want to have to load my provisioning profiles on their devices.

#!/bin/sh

TEMPDIR=/tmp/$RANDOM-$RANDOM-$RANDOM
RESOURCERULES=/tmp/ResourceRules-$RANDOM$RANDOM.plist
CURRENTDIR=`pwd`

mkdir -p "$TEMPDIR"

cat - > "$RESOURCERULES" <<ResourceRulesPlistDelimiter
<?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>
ResourceRulesPlistDelimiter

unzip -q "$1" -d "$TEMPDIR" || exit 1
xattr -d -r com.apple.quarantine "$TEMPDIR"

for APPBUNDLE in "`find "$TEMPDIR" -name "*.app"`"; do
    codesign --resource-rules="$RESOURCERULES" -f -s "iPhone Developer" "$APPBUNDLE"
    codesign -dvvvv -r- "$APPBUNDLE"
done

cd "$TEMPDIR"
zip -qr "$TEMPDIR.zip" "Payload" && cd "$CURRENTDIR" && mv "$1" "$1.bak" && mv "$TEMPDIR.zip" "$1"
cd "$CURRENTDIR"
rm -rf "$TEMPDIR.zip"
rm -rf "$TEMPDIR"
rm -rf "$RESOURCERULES"