We do something similar for our latest app (in review), albeit a bit more complicated. This would go after copy resources however since it modifies the info.plist in the app after it's built. This has the advantage of basing your version number off of the svn version and not marking your info plist modified (and thus leading to endless commits). Lastly, it will also write your version into your Settings.bundle if you have one which can be nice.
It handles some weird cases with paths we've run into as well.
->Ben
(uses) /bin/bash
STRIPPED_BASE_DIR=`echo ${TARGET_BUILD_DIR} | sed -e 's/"//g'`
INFOPLIST_TARGET_PATH="${STRIPPED_BASE_DIR}/${INFOPLIST_PATH}"
SETTINGS_ROOTPLIST="${STRIPPED_BASE_DIR}/${WRAPPER_NAME}/Settings.bundle/Root.plist"
REV=`svnversion -nc | /usr/bin/sed -e 's/^[^:]*://;s/[A-Za-z]//'`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${REV}" "${INFOPLIST_TARGET_PATH}"
# after this point we're just writing a human readable version into the Settings.bundle for an iOS app
# this is the key you want the version number stored in your NSUserDefaults under, make sure it appears in Settings.bundle/Root.plist
DEFAULTS_VERSION_KEY="ATSFullVersionString"
VER=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "${INFOPLIST_TARGET_PATH}"`
# ex: 1.0 (395)
HUMAN_VERSION_STRING="${VER} (${REV})"
# Check to see if Settings.bundle/Root.plist exists, otherwise does nothing (e.g. on Mac, if you don't use a Settings.bundle, etc.)
if [ -e ${SETTINGS_ROOTPLIST} ]; then
# this checks the first 15 entries in the root.plist for a key matching our version number
for i in {0..15}; do
CURRENT_KEY=`/usr/libexec/PlistBuddy -c "Print PreferenceSpecifiers:${i}:Key" "${SETTINGS_ROOTPLIST}"`
if [ "${CURRENT_KEY}" == "${DEFAULTS_VERSION_KEY}" ]
then
/usr/libexec/PlistBuddy -c "Set PreferenceSpecifiers:${i}:DefaultValue ${HUMAN_VERSION_STRING}" "${SETTINGS_ROOTPLIST}"
break
fi
done
fi