XCode BuildVersion 自增配置

2016-10-11  本文已影响57人  ChasonTse

Xcode Project -> TARGETS -> Build Phases -> “+” -> New Run Script Build Phases

在新出现的Run Script栏中, 于Shell输入框中输入如下脚本:

#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"

如果想只在非Debug模式下生效,则添加判断:

#!/bin/bash
if [ $CONFIGURATION != Debug ]; then
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
fi

如图所示:

如图所示
上一篇下一篇

猜你喜欢

热点阅读