Created
April 13, 2018 07:46
-
-
Save jnutting/b7d8bd0ecf88913e91cb67d8d1961266 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/sh | |
# | |
# Run this as an Xcode build phase in order to always set the build number | |
# of a freshly-built app equal to the number of commits in the master branch. | |
# This gives you an always-increasing build number, automatically. | |
# | |
# This sets the build number only in the build product, not in the source | |
# directory itself, so it doesn't dirty the repository. You can leave the | |
# build number in the Xcode project to "1" forever. | |
git=$(sh /etc/profile; which git) | |
echo "found git $git" | |
target_plist="$TARGET_BUILD_DIR/$INFOPLIST_PATH" | |
dsym_plist="$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Info.plist" | |
number_of_commits=$("$git" rev-list master | wc -l | tr -d ' ') | |
echo "set number_of_commits $number_of_commits" | |
#git_release_version=$("$git" describe --tags --always --abbrev=0) | |
#echo "set git_release_version $git_release_version" | |
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