Xcode打包实用技巧之自动增加编译版本号

在Targets - Build Phases 里面

Paste_Image.png
Paste_Image.png

代码如下:

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

完整的效果:


Paste_Image.png

推荐阅读更多精彩内容