1.获得Entitlements.plist文件
#!/bin/sh codesign -d --entitlements - myapp.app
Entitlements文件形如
<?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>application-identifier</key> <string>XXXXXXX.bundleid</string> <key>com.apple.developer.team-identifier</key> <string>XXXXXXX</string> <key>com.apple.security.application-groups</key> <array/> <key>get-task-allow</key> <true/> </dict> </plist>
其中XXXXX为签名证书的组织单位,可通过钥匙串工具查看;bundleid不用多说了。本例只是一个例子,具体问题具体分析。
2.重签名并生成新的ipa
#!/bin/sh
oldipaname="codesigndemo"
mobileprovisionname="bundle.mobileprovision"
distributionname="iPhone Developer: ********"
entitlements="Entitlements.plist"
#解压ipa
oldipa="$oldipaname.ipa"
unzip $oldipa
#更换证书
oldapp="$oldipaname.app"
cp $mobileprovisionname Payload/$oldapp/embedded.mobileprovision
#重签名
echo $oldapp
codesign -f -s $distributionname --entitlements $entitlements Payload/$oldapp
#重新生成ipa
newipa="$oldipaname-new.ipa"
path=$(pwd)
xcrun -sdk iphoneos PackageApplication -v Payload/$oldapp -o $path/$newipa
rm -r Payload