Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Grabs the latest tag and sets the version number. You must only have version numbers as tags and they must be in format "X.y[.z]-B" where: X, y are major and minor versions; z (patch version) is optional; and B is the build number. Execute this with a post-build script phase similar to this:
# Get the current version and extract the version/build from there
LATEST_TAG=`xcrun git describe --tags --abbrev=0`
# Set the new version
defaults write "${PLIST_PATH%.*}" 'CFBundleVersion' "${NEW_BUILD_NUM}" &> /dev/null
BUILD_NUM_SET=`defaults read "${PLIST_PATH%.*}" 'CFBundleVersion'`
echo "Set build number to ${BUILD_NUM_SET} in ${INFOPLIST_PATH}"
# Tag it!
xcrun git tag ${TAG_VERSION}-${BUILD_NUM_SET}
xcrun git push origin --tags
echo "Bumped and tagged."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.