Skip to content

Instantly share code, notes, and snippets.

@songzhou21
Last active August 1, 2016 07:13
Show Gist options
  • Save songzhou21/c6e636e31fdd80c7ae5cc1edf5f7f410 to your computer and use it in GitHub Desktop.
Save songzhou21/c6e636e31fdd80c7ae5cc1edf5f7f410 to your computer and use it in GitHub Desktop.
update build number for Xcode project with SVN
#!/bin/bash
# before commit, run this script will set build number to recent SVN revision number
# run this script in project directory
echo "Update build number"
echo "get revision number from SVN..."
svn_info=$(svn info -r 'HEAD')
if [[ $? != 0 ]]; then
exit $?
fi
bN=$(echo "$svn_info" | grep Revision | egrep -o "[0-9]+")
echo "build number is $bN"
if [ -z "$bN" ] || [ "$bN" -lt "1" ]; then
echo "build nubmer $bN not valid"
exit 1
fi
# handle connecting error
if [[ $? != 0 ]]; then
echo "connecting SVN with error($?)"
exit $?
fi
# find info.plist
info_plist_file="$PWD/YOUR_PROJECT_NAME-info.plist"
if [ ! -f $info_plist_file ]; then
echo "$info_plist_file not found, you must run this script in Project
Directory, e.g., ~/Developer/YOUR_PROJECT_NAME/"
exit 1;
fi
echo "set build number to $bN"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bN" "$info_plist_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment