Shell实现iOS项目build打包后自动+1

applecarelte 2020-06-05

把下面的代码放到run Script中,感兴趣的,代码不懂的可以学一下shell!

Shell实现iOS项目build打包后自动+1

# Type a script or drag a script file from your workspace to insert its path.
if [ $CONFIGURATION == Release ]; then
echo "当前为 Release Configuration,开始自增 Build"
plist=${INFOPLIST_FILE}
buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}")
if [[ "${buildnum}" == "" ]]; then
echo "Error:在Plist文件里没有 Build 值"
exit 2
fi
buildnum=$(expr $buildnum + 1)
/usr/libexec/PlistBuddy -c "Set CFBundleVersion $buildnum" "${plist}"
else
echo $CONFIGURATION "当前不为 Release Configuration"
fi

相关推荐