So lets start with I’m not a developer. I won’t pretend to be one but I do find development work quite interesting. One thing I’m trying to get into is Swift but even the small steps lead me to realize how large the Apple ecosystem is. Cocoa, Swift, Xcode, System frameworks, finding the right documentation, etc. The process of connecting the dots takes a bit of time as you might imagine.

One of the first tasks I wanted to do was auto update the CFBundleVersion whenever I added a commit via git. This is a solved problem but I didn’t see any videos covering this topic so I thought I’d make one. Hat tip to Tim Sutton as I stole his script that he added to Imagr.

The script:

# based on
if git rev-parse --is-inside-work-tree 2> /dev/null > /dev/null; then
echo "Setting CFBundleVersion to Git rev-list --count"
build_number=$(git rev-list HEAD --count)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $build_number" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
echo "Not in a Git repo, not setting CFBundleVersion"