iOS APP 重签名

2018-04-18  本文已影响77人  Will_Z_jwz
参考文章:https://objccn.io/issue-17-2/

签名流程

$ cp ~/Desktop/embedded.mobileprovision Payload/ipaName.app/embedded.mobileprovision
$ security cms -D -i "xxx.mobileprovision"
//使用该命令进行查看xxx.mobileprovision文件的相关内容,可以找到以Entitlements为key的字典值。
//新建一个.plist文件,将上述值复制到plist文件中。如下示例:
<?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>keychain-access-groups</key>
    <array>
        <string>AD9JDJKJKA.*</string>
    </array>
    <key>get-task-allow</key>
    <false/>
    <key>application-identifier</key>
    <string>AD9JDJKJKA.com.resign.test</string>
    <key>com.apple.developer.team-identifier</key>
    <string>AD9JDJKJKA</string>
    <key>aps-environment</key>
    <string>production</string>
    <key>beta-reports-active</key>
    <true/>
</dict>
</plist>
    codesign -f -s "iPhone Distribution: ******* Co., Ltd." --entitlements entitlements.plist  Payload/ipaName.app
entitlements.plist
# !/bin/bash
SOURCEIPA="/Users/maccarduo/Desktop/wechat.ipa"
MOBILEPROV="/Users/maccarduo/Desktop/embedded.mobileprovision"
#DYLIB="/Users/maccarduo/Desktop/FishChat.dylib"

cd ${SOURCEIPA%/*}

security find-identity -v -p codesigning > cers.txt
while IFS='' read -r line || [[ -n "$line" ]]; do
    if [[ "$line" =~ "iPhone Developer" ]]; then
      DEVELOPER=${line:47:${#line}-48}
    fi
done < cers.txt

unzip -qo "$SOURCEIPA" -d extracted

APPLICATION=$(ls extracted/Payload/)

echo "Copying dylib and mobileprovision"
cp "$DYLIB" "extracted/Payload/$APPLICATION/${DYLIB##*/}"
cp "$MOBILEPROV" "extracted/Payload/$APPLICATION/embedded.mobileprovision"

echo "Insert dylib into Mach-O file"
yololib "extracted/Payload/$APPLICATION/${APPLICATION%.*}" "${DYLIB##*/}"

echo "Resigning with certificate: $DEVELOPER"
find -d extracted  \( -name "*.app" -o -name "*.appex" -o -name "*.framework" -o -name "*.dylib" \) > directories.txt
security cms -D -i "extracted/Payload/$APPLICATION/embedded.mobileprovision" > t_entitlements_full.plist
/usr/libexec/PlistBuddy -x -c 'Print:Entitlements' t_entitlements_full.plist > t_entitlements.plist
while IFS='' read -r line || [[ -n "$line" ]]; do
    /usr/bin/codesign --continue -f -s "$DEVELOPER" --entitlements "t_entitlements.plist"  "$line"
done < directories.txt

echo "Creating the Signed IPA"
cd extracted
zip -qry ../extracted.ipa *
cd ..

rm -rf "extracted"
rm directories.txt
rm cers.txt
rm t_entitlements.plist
rm t_entitlements_full.plist
echo "Installing APP to your iOS Device"
mobiledevice install_app extracted.ipa

 rm extracted.ipa

通过将命令合并写到一个autoswimfi.sh文件中(如果无法执行,打开终端,输入:chmod 777 autoswimfi.sh 给该文件赋予权限),可以一步到位执行命令。

上一篇下一篇

猜你喜欢

热点阅读