問題
在 App 上傳到 App Store Content 審查過程中, 我們可能會遇到如下警告錯誤, 通常會發(fā)送郵件給我們。
Dear Developer,
We identified one or more issues with a recent delivery for your app, "Awesome App". Your delivery was successful, but you may wish to correct the following issues in your next delivery:
CFBundleVersion Mismatch - The CFBundleVersion value '8' of extension 'Awesome.app/PlugIns/Awesome.app-share.appex' does not match the CFBundleVersion value '10' of its containing iOS application 'Awesome.app'.
CFBundleVersion Mismatch - The CFBundleVersion value '8' of extension 'Awesome.app/PlugIns/Awesome.app.widget.appex' does not match the CFBundleVersion value '10' of its containing iOS application 'Awesome.app'.
After you’ve corrected the issues, you can use Xcode or Application Loader to upload a new binary to App Store Connect.
Best regards,
The App Store Team
正常情況下我們通過手動修改多個target版本或者build號保持一致, 重新上傳即可解決問題悉盆。這里我嘗試來實(shí)現(xiàn)了一種自動設(shè)置的方式, 能夠避免每次都手動設(shè)置的煩惱。
實(shí)現(xiàn)方式
添加 Shell 腳本; 在Xcode Build Phases -> 添加 Run Script;
腳本實(shí)現(xiàn)
功能
- Release 環(huán)境下 App 主 target build 號自增;
- 其他 Extension Target 保持和主版本的版本號 build號一致; $ExtensionName為 Extension Target 的名字, 根據(jù)需求自己可以做出調(diào)整。
if [ $CONFIGURATION == Release ]; then
echo "Bumping build number..."
plist=${INFOPLIST_FILE}
buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}")
if [[ "${buildnum}" == "" ]]; then
echo "No build number in $plist"
exit 2
fi
echo "Bumped build number to $buildnum"
buildnum=$(expr $buildnum + 1)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildnum" "${INFOPLIST_FILE}"
echo "Update build number to Current Project Version"
agvtool new-version -all $buildnum
echo "Keep Extension Target build version and number as same as app"
buildver=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plist}")
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $buildver" "$SRCROOT/$ExtensionName/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $buildver" "$SRCROOT/$ExtensionName/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildnum" "$SRCROOT/$ExtensionName/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildnum" "$SRCROOT/$ExtensionName/Info.plist"
else
echo $CONFIGURATION "build - Not bumping build number."
fi