# Set the build number to the current git commit count. # # Permanent home: # https://gist.github.com/jaredsinclair/af6898f93674ee5923f3 # # Based on: http://w3facility.info/question/how-do-i-force-xcode-to-rebuild-the-info-plist-file-in-my-project-every-time-i-build-the-project/ # Updated with dSYM handling from http://yellowfeather.co.uk/blog/auto-incrementing-build-number-in-xcode-revisited/ git=`sh /etc/profile; which git` appBuild=`"$git" rev-list HEAD --count` settingsBundleDir="${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}/Settings.bundle" settingsPlist="${settingsBundleDir}/Root.plist" appVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" ) /usr/libexec/PlistBuddy -c "Set :PreferenceSpecifiers:1:DefaultValue $appVersion" "${settingsPlist}" /usr/libexec/PlistBuddy -c "Set :PreferenceSpecifiers:2:DefaultValue $appBuild" "${settingsPlist}" /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}.dSYM/Contents/Info.plist" echo "Incremented the build number ${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"