这个脚本有个问题就是Xcode页面有时不能及时刷新,得切换页面才能得到刷新。
按编译build号自增
#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
按时间自增
#!/bin/bash
buildNumber=$(date +%Y%m%d%H%M%S)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
按git commit总数作为build号
#!/bin/bash
if [ $CONFIGURATION = "Debug" ]; then
git=`sh /etc/profile; which git`
appBuild=`"$git" rev-list --all |wc -l`
buildNumber=$appBuild
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
fi