ipa重签名的文章应该比较多,但是涉及到内嵌多个framework的签名可能介绍的就比较少了。
当然,其实内嵌framework的签名其实也很简单,步骤如下:
- 导出entitlements.plist
- 对framework单独签名
- 对ipa签名
准备材料:
- p12 安装到keychain
- certificate安装到keychain
- mobileprovision,为了方便操作,可放置在ipa同一目录
- ipa 需要重签名的ipa
签名过程:
说明,如下过程中embedded为笔者项目特有,通常项目无需包含。
如果您还需要修改bundle identifier,那么请参考 plutil命令。
示例:
#!/bin/sh
# ResignScript.sh
#
#
# Created by W3Mobile Server on 6/1/2016.
# It needs *.mobileprovision and *.ipa file in same folder.
#
# unpackage
echo "0. read paramter"
#theVersion=""
#
#if [ $# -ge 1 ]; then
# theVersion=$1
#else
# echo "Please set version as first paramter"
# exit
#fi
resignRoot=$PWD
certfierName="iPhone Distribution: Huawei Technologies Co., Ltd."
appFolder=""
echo "1. unpackage ipa"
rm -rf ./Payload
rm -rf resigned.ipa
unzip *.ipa >> resign.log
# search app floder
for app_item in ./Payload/*.app
do
if test -d $app_item
then
appFolder=$app_item
fi
done
if [ ${appFolder}x != "x" ]; then
echo "Did found app:"$appFolder
else
echo "No ipa found."
rm -rf resign.log
exit
fi
# copy embedded.mobileprovision
echo "2. copy embedded.mobileprovision"
rm -rf ${appFolder}/embedded.mobileprovision
cp ./*.mobileprovision ${appFolder}/embedded.mobileprovision
cd ${appFolder}/Embedded/
for zip_item in *.zip
do
unzip -q $zip_item
rm -rf $zip_item
done
cd $resignRoot
for bundle_item in ${appFolder}/Embedded/*.framework
do
if test -d $bundle_item
then
cp ./*.mobileprovision ${bundle_item}/embedded.mobileprovision
fi
done
echo "3. export entitlements.plist"
rm -rf ./entitlements.plist
codesign -d --entitlements=entitlements.plist ${appFolder}
echo "4. resign app"
rm -rf ${appFolder}/Embedded/Embedded.plist
cp ./Embedded.plist ${appFolder}/Embedded/Embedded.plist
cd ${appFolder}/Embedded/
for bundle_item in *.framework
do
if test -d $bundle_item
then
bunleName=${bundle_item%%.framework}
codesign -f -s "$certfierName" --entitlements=${resignRoot}/entitlements.plist ${bundle_item}
zip -q -r ${bunleName}.zip $bundle_item
rm -rf $bundle_item
fi
done
cd $resignRoot
for fmwk_item in ${appFolder}/Frameworks/*.framework
do
codesign -f -s "$certfierName" --entitlements=entitlements.plist ${fmwk_item}
done
codesign -f -s "$certfierName" --entitlements=entitlements.plist ${appFolder}
echo "5. package ipa ..."
zip -r resigned.ipa ./Payload/ >> resign.log
echo "6. clean ..."
rm -rf resign.log
rm -rf ./entitlements.plist
rm -rf ./Payload
echo "7. done."