Created
April 14, 2015 23:55
-
-
Save marclove/e93feefc1e72c663acb9 to your computer and use it in GitHub Desktop.
Xcode Build Script to automatically set Version & Build Number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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