Skip to content

Instantly share code, notes, and snippets.

@viktorbenei
Created April 28, 2014 10:10
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 viktorbenei/11367575 to your computer and use it in GitHub Desktop.
Save viktorbenei/11367575 to your computer and use it in GitHub Desktop.
Auto increment build number of Xcode project
#
# Paste this into a new "Run Script" Build Phase (as described here: http://stackoverflow.com/a/15483906/974381)
#
# Tip: drag-and-drop your new Run Script to run before the "Compile Sources" Phase!
#
# Source: http://stackoverflow.com/a/15483906/974381
#
# How to get version numbers in code?
# NSString *buildString = infoDictionary[(NSString*)kCFBundleVersionKey];
# NSString *versionString = infoDictionary[@"CFBundleShortVersionString"];
#
#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment