Skip to content

Instantly share code, notes, and snippets.

@ddaws
Created February 28, 2015 22:14
Show Gist options
  • Save ddaws/ceb3f89ca941691f8457 to your computer and use it in GitHub Desktop.
Save ddaws/ceb3f89ca941691f8457 to your computer and use it in GitHub Desktop.
Update plist CFBundleVersion
#!/bin/sh
PLIST_FILE_NAME="Info.plist"
plist="${SRCROOT}/${PROJECT}/${PLIST_FILE_NAME}"
dir="${SRCROOT}/.."
# Only increment the build number if source files have changed
if [ -n "$(find "$dir" \! -path "*xcuserdata*" \! -path "*.git" -newer "$plist")" ]; then
buildnum=$(/usr/libexec/Plistbuddy -c "Print CFBundleVersion" "$plist")
if [ -z "$buildnum" ]; then
echo "No build number in $plist"
exit 2
fi
buildnum=$(expr $buildnum + 1)
/usr/libexec/Plistbuddy -c "Set CFBundleVersion $buildnum" "$plist"
echo "Incremented build number to $buildnum"
else
echo "Not incrementing build number as source files have not changed"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment