公司做的做的是强大的视频监控,很多厂家表示感兴趣,合作的公司多了,定制的APP暴增,每次发布版本都要同时发若干的版本,一旦证书被修改,很头大~
之前找的一些都没有对私有库重签名~现在整合一下,尝试居然成功了~望能给广大同胞带来福音。。。
#ipa包路径
ORIGINAL_FILE=$"/Users/MartinLee/Desktop/..."
#证书名常用名称
CERTIFICATE=$"iPhone Distribution: XXXXXX CO.,LTD. (XXXXXXXX)"
#证书路径
MOBILEPROVISION=$"/Users/MartinLee/Desktop/XXXXXXXXXX.mobileprovision"
#重新签名后的bundle_id
BUNDLE_ID=$"co.jp.Divey"
#重签名打包后ipa的存放路径
TARGET=$"/Users/MartinLee/Desktop/Resign"
#Mac的密码
PASSWD=$MartinLee
function unzip_IPA()
{
ipa="$ORIGINAL_FILE"
unzip -o "$ipa" -d extracted
}
function create_EntitlementsPlist()
{
/usr/libexec/PlistBuddy -x -c "print :Entitlements " /dev/stdin <<< $(security cms -D -i ${MOBILEPROVISION}) > entitlements.plist
SN_CODE=$(/usr/libexec/PlistBuddy -c "Print :com.apple.developer.team-identifier" entitlements.plist)
/usr/libexec/PlistBuddy -c "Set :application-identifier ${SN_CODE}.${BUNDLE_ID}" entitlements.plist
}
function set_BundleID()
{
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $BUNDLE_ID" extracted/Payload/*.app/Info.plist
}
function del_OldCodeSign()
{
rm -r extracted/Payload/*.app/_CodeSignature/
}
function copy_EmbeddedProvision()
{
cp $MOBILEPROVISION extracted/Payload/*.app/embedded.mobileprovision
}
function reSignFrameworks(){
echo "Resigning with certificate: $CERTIFICATE" >&2
find -d extracted \( -name "*.app" -o -name "*.appex" -o -name "*.framework" -o -name "*.dylib" \) > directories.txt
while IFS='' read -r line || [[ -n "$line" ]]; do
/usr/bin/codesign --continue -f -s "$CERTIFICATE" --no-strict "t_entitlements.plist" "$line"
done < directories.txt
}
function reSign()
{
codesign -f -s "$CERTIFICATE" --entitlements entitlements.plist extracted/Payload/*.app/
}
function rezip_IPA()
{
cd extracted
zip -qry ../NEW.ipa *
cd ..
mv NEW.ipa "$TARGET"
}
security unlock-keychain -p "$PASSWD" ~/Library/Keychains/login.keychain
unzip_IPA
create_EntitlementsPlist
set_BundleID
del_OldCodeSign
copy_EmbeddedProvision
reSignFrameworks
reSign
rezip_IPA
rm -rf "extracted"
rm directories.txt
rm entitlements.plist