Skip to content

Instantly share code, notes, and snippets.

@Numan1617
Created April 8, 2014 08:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Numan1617/dff95e1332dd14cc87c3 to your computer and use it in GitHub Desktop.
Save Numan1617/dff95e1332dd14cc87c3 to your computer and use it in GitHub Desktop.
iOS - Automatic Version Numbering
# Use last tag as the base for the version. E.g. tag initial commit as 0.0
LAST_TAG_VERSION=`git describe --tags | cut -f1 -d"-"`
# Optional. Same as above but keeps the commit hash
#LAST_TAG_VERSION=`git describe --tags`
# Total number of commits in the repository
TOTAL_COMMITS=`git rev-list HEAD --count`
# Write the version numbers to the compiled product
defaults write "${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH%.*}" "CFBundleShortVersionString" "${LAST_TAG_VERSION#*v}.${TOTAL_COMMITS}"
defaults write "${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH%.*}" "CFBundleVersion" "${LAST_TAG_VERSION#*v}.${TOTAL_COMMITS}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment