Advertisement
undeadhip

Untitled

Aug 28th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # xcode-version-bump.sh
  2. # @desc Auto-increment the version number (only) when a project is archived for export.
  3. # @usage
  4. # 1. Select: your Target in Xcode
  5. # 2. Select: Build Phases Tab
  6. # 3. Select: Add Build Phase -> Add Run Script
  7. # 4. Paste code below in to new "Run Script" section
  8. # 5. Check the checkbox "Run script only when installing"
  9. # 6. Drag the "Run Script" below "Link Binaries With Libraries"
  10. # 7. Insure your starting version number is in SemVer format (e.g. 1.0.0)
  11.  
  12. # This splits a two-decimal version string, such as "0.45.123", allowing us to increment the third position.
  13. VERSIONNUM=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")
  14. NEWSUBVERSION=`echo $VERSIONNUM | awk -F "." '{print $3}'`
  15. NEWSUBVERSION=$(($NEWSUBVERSION + 1))
  16. NEWVERSIONSTRING=`echo $VERSIONNUM | awk -F "." '{print $1 "." $2 ".'$NEWSUBVERSION'" }'`
  17. /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $NEWVERSIONSTRING" "${PROJECT_DIR}/${INFOPLIST_FILE}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement