如何重新签署从App Store下载的ipa文件?

时间:2018-01-03 11:54:42

标签: ios xcode ipa

使用此脚本,从AppStore下载的已重新签名的IPA文件,在iphone设备中启动但在应用程序上单击时无法打开应用程序 它打开和关闭(像闪屏一样)。

sign.sh

# !/bin/bash
SOURCEIPA="$1"
DEVELOPER="$2"
MOBILEPROV="$3"
TARGET="$4"
BUNDLE="$5"

unzip -qo "$SOURCEIPA" -d extracted

APPLICATION=$(ls extracted/Payload/)

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
echo "Changing BundleID with : $BUNDLE"
/usr/libexec/PlistBuddy -c "Set:CFBundleIdentifier $BUNDLE" "extracted/Payload/$APPLICATION/Info.plist"
fi
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
#/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

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

rm -rf "extracted"
rm directories.txt
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

你需要在mac中使用终端运行以下脚本文件,在终端("/signall.sh")中给出下面文件的路径

  

注意:provisional profile,Distribution Certificate,Ipa File和这两个脚本shell文件应该在同一个文件夹中,以便它在内部执行所有文件。

signall.sh

# !/bin/bash
signscript="<path of File sign.sh>"
ipasourcefolder="<path of Ipa File>"
ipadestfolder="<path of ipa destination file to store after Resign resign>"

developer1="iPhone Distribution certificate"
mobileprovision1="provision certificate path"

bundleid="null.null" #use null.null if you want to use the default app bundleid


cd $ipasourcefolder
find -d . -type f -name "*.ipa"> files.txt
while IFS='' read -r line || [[ -n "$line" ]]; do
filename=$(basename "$line" .ipa)
echo "Ipa: $filename"
#_dev1_______
output=$ipadestfolder$filename
output+=".ipa"
"$signscript" "$line" "$developer1" "$mobileprovision1" "$output" "$bundleid"
done < files.txt
rm files.txt
  1. 以上代码是否存在任何问题,为什么我的应用程序在设备中安装但无法打开?
  2. 以上方法是从Appstore重新签名Ipa文件的正确方法吗?

0 个答案:

没有答案