本文主要是介绍Xcode打包,仅archive时通过Run Script脚本进行build号自增,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Run Script脚本
不知Xcode如何添加shell脚本?请看文章结尾^_^
网上一般都是release模式下build号自增,这里是根据archive进行的(每次打包build号++),大同小异,看实际需要吧,直接上代码了
if [ $ACTION == install ]; then
echo "Bumping build number..."
echo $ACTION
plist=${PROJECT_DIR}/${INFOPLIST_FILE}#increment the build number (ie 115 to 116)
buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}")
if [[ "${buildnum}" == "" ]]; then
echo "No build number in $plist"
exit 2
fibuildnum=$(expr $buildnum + 1)
/usr/libexec/Plistbuddy -c "Set CFBundleVersion $buildnum" "${plist}"
echo "Bumped build number to $buildnum"else
echo $CONFIGURATION " build - Not bumping build number."fi
正文结束
--------------------------------------------------分割线---------------------------------------------------
附:如果向根据release进行自增,代码如下
if [ $CONFIGURATION == Release ]; then
echo "Bumping build number..."
plist=${PROJECT_DIR}/${INFOPLIST_FILE}#increment the build number (ie 115 to 116)
buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}")
if [[ "${buildnum}" == "" ]]; then
echo "No build number in $plist"
exit 2
fibuildnum=$(expr $buildnum + 1)
/usr/libexec/Plistbuddy -c "Set CFBundleVersion $buildnum" "${plist}"
echo "Bumped build number to $buildnum"else
echo $CONFIGURATION " build - Not bumping build number."fi
附:Xcode如何增加Run Script脚本
然后选择“New Run Script Phase”
然后加入代码即可,如下
这篇关于Xcode打包,仅archive时通过Run Script脚本进行build号自增的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!