Xcode script on build to update version number string in Settings.bundle Xcode script on build to update version number string in Settings.bundle xcode xcode

Xcode script on build to update version number string in Settings.bundle


You can add a run script phase for your target (build phases > add build phase > add run script). Then you will have a shell script where you could use PlistBuddy to get the version string and set it in your other plist.

For example :

/usr/libexec/PlistBuddy -c "print:CFBundleVersion" "$CONFIGURATION_BUILD_DIR/$INFOPLIST_PATH"

will display the version string of your app. If you record this in a variable and set the value on the other plist using Plist Buddy -c set, you will be done.

This would give something like :

versionString=$(/usr/libexec/PlistBuddy -c "print:CFBundleVersion" "$CONFIGURATION_BUILD_DIR/$INFOPLIST_PATH")/usr/libexec/PlistBuddy -c "Set CURRENT_VERSION_NO $versionString" "$THE_PATH_TO_YOUR_PLIST_FILE"

I never used PlistBuddy -c copy but it should allow you to do this in only one line.