Skip to content

Instantly share code, notes, and snippets.

@marclove
Created April 14, 2015 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marclove/e93feefc1e72c663acb9 to your computer and use it in GitHub Desktop.
Save marclove/e93feefc1e72c663acb9 to your computer and use it in GitHub Desktop.
Xcode Build Script to automatically set Version & Build Number
git=$(sh /etc/profile; which git)
latest_tag=$("$git" describe --tags --always --abbrev=0)
version_string="${git_release_version#*v}" # assumes the following tag format: v1.2.3
number_of_commits=$("$git" rev-list <$$$$$$-YOUR DEVELOPMENT BRANCH NAME HERE-$$$$$$> | wc -l | tr -d ' ')
target_plist="$TARGET_BUILD_DIR/$INFOPLIST_PATH"
dsym_plist="$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Info.plist"
for plist in "$target_plist" "$dsym_plist"; do
if [ -f "$plist" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $number_of_commits" "$plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${git_release_version#*v}" "$plist"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment