升级到xcode11,打包出现这个错误
$(CURRENT_PROJECT_VERSION) + 1: syntax error: operand expected (error token is "$(CURRENT_PROJECT_VERSION) + 1") 如下图
查询相关资料后发现问题的原因是:
在xcode 11中,在项目的构建设置中有一个新的部分叫做版本控制
并且CFBundleShortVersionString
自动更改为$(MARKETING_VERSION),
CFBundleVersion会改为$(CURRENT_PROJECT_VERSION)(测试发现只要手动修改这个再打包就会变化)。
要从Target-Info中看到
这就需要修改自增的脚本了
升级之前的自增脚本:
echo $CONFIGURATION
if [ "Release" == "${CONFIGURATION}" ]
then
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"
echo "build number increase"
fi
升级后的脚本:
echo $CONFIGURATION
if [ "Release" == "${CONFIGURATION}" ]
then
buildNumber=$CURRENT_PROJECT_VERSION
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"
echo "build number increase"
fi
参考:https://www.ojit.com/article/778758