How to auto-increment Bundle Version in Xcode 4?

后端 未结 9 904
情书的邮戳
情书的邮戳 2020-12-12 16:43

I am trying to figure out how to have the Bundle version number increment automatically in my Xcode 4 project (for ad-hoc and release builds). I found some scripts online th

9条回答
  •  生来不讨喜
    2020-12-12 16:55

    If you're using a version system like "x.x.x" you can add this run script. It'll increase the version number (x.x.x+1) every time a new build is made:

    if [ "${CONFIGURATION}" != "Debug" ]; then
    
    VERSIONNUM=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
    
    NEWSUBVERSION=`echo $VERSIONNUM | awk -F "." '{print $4}'`
    
    NEWSUBVERSION=$(($NEWSUBVERSION + 1))
    
    NEWVERSIONSTRING=`echo $VERSIONNUM | awk -F "." '{print $1 "." $2 "." $3 ".'$NEWSUBVERSION'" }'`
    
    /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $NEWVERSIONSTRING" "${PROJECT_DIR}/${INFOPLIST_FILE}"
    
    fi
    

提交回复
热议问题