What do Xcode Project Versioning settings do?

I'm trying to figure out what the Versioning settings (such as MARKETING_VERSION, CURRENT_PROJECT_VERSION, etc) under the PROJECT / BUILD SETTINGS tab do.

The version numbers embedded in the binary, etc. seem to be taken from the TARGETS / BUILD SETTINGS tab, which beg the question regarding the PROJECT settings.

I ended up down this rabbit hole because I wanted to automate my versioning settings, but agvtool doesn't work with things like the standard macos app template because agvtool seems to assume an Info.plist file (from what I can tell). I suspect I'll have to parse the project.pbxproj file.

Running Xcode 14.0 beta 2.

Answered by mikeyh in 718911022

MARKETING_VERSION (CFBundleShortVersionString in Info.plist): https://developer.apple.com/documentation/xcode/build-settings-reference#Marketing-Version

CURRENT_PROJECT_VERSION (CFBundleVersion in Info.plist): https://developer.apple.com/documentation/xcode/build-settings-reference#Current-Project-Version

CFBundleShortVersionString: https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring

CFBundleVersion: https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion (important for App Store updates)

Targets inherit from project settings so you could just set the CURRENT_PROJECT_VERSION and MARKETING_VERSION in the project, delete the target specific build settings and each target will then use the project settings.

Customised / Levels at the top left of build settings helps to see what is customised or inherited in each target.

You can also use build configuration files to specify build settings for the project or specific targets / configurations which are often easier for scripts to update, avoiding any parsing of project.pbxproj files: https://developer.apple.com/documentation/xcode/adding-a-build-configuration-file-to-your-project

eg setting the following project.xcconfig for all configurations (and removing CURRENT_PROJECT_VERSION / MARKETING_VERSION from the project / target build settings) will use the xconfig versions for all targets:

project.xcconfig

CURRENT_PROJECT_VERSION = 1.0.0
MARKETING_VERSION = 1.0

You can also reference custom build settings just like any other build setting. eg $(MY_CUSTOM_BUILD_SETTING)

One of my projects uses xcconfig to manage custom TOOLS_OWNED / HELPER_AUTHORISED_CLIENTS (SMPrivilegedExecutables / SMAuthorizedClients) build settings for multiple targets and debug / release / distribution configurations as an alternative to SMJobBlessUtil-python3.py updating Info.plist files.

AFAIK, versioning settings are used at least in the AppStore to check version increase between releases.

Accepted Answer

MARKETING_VERSION (CFBundleShortVersionString in Info.plist): https://developer.apple.com/documentation/xcode/build-settings-reference#Marketing-Version

CURRENT_PROJECT_VERSION (CFBundleVersion in Info.plist): https://developer.apple.com/documentation/xcode/build-settings-reference#Current-Project-Version

CFBundleShortVersionString: https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring

CFBundleVersion: https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion (important for App Store updates)

Targets inherit from project settings so you could just set the CURRENT_PROJECT_VERSION and MARKETING_VERSION in the project, delete the target specific build settings and each target will then use the project settings.

Customised / Levels at the top left of build settings helps to see what is customised or inherited in each target.

You can also use build configuration files to specify build settings for the project or specific targets / configurations which are often easier for scripts to update, avoiding any parsing of project.pbxproj files: https://developer.apple.com/documentation/xcode/adding-a-build-configuration-file-to-your-project

eg setting the following project.xcconfig for all configurations (and removing CURRENT_PROJECT_VERSION / MARKETING_VERSION from the project / target build settings) will use the xconfig versions for all targets:

project.xcconfig

CURRENT_PROJECT_VERSION = 1.0.0
MARKETING_VERSION = 1.0

You can also reference custom build settings just like any other build setting. eg $(MY_CUSTOM_BUILD_SETTING)

One of my projects uses xcconfig to manage custom TOOLS_OWNED / HELPER_AUTHORISED_CLIENTS (SMPrivilegedExecutables / SMAuthorizedClients) build settings for multiple targets and debug / release / distribution configurations as an alternative to SMJobBlessUtil-python3.py updating Info.plist files.

10

Thanks so much for your detailed response. I wondered whether it was supposed to inherit, but couldn't get that to work. (I wasn't advanced enough to understand the "levels" setting or to look at that). It turns out the Apple build template overrode the default and the way to reset a default is to highlight the row and hit delete. (Don't try leaving it blank, or setting it back how you found it after the build template set it) Next task is explore your build configuration advice. @obscurebug

This was something I looked at again recently. My last post about versions and auto incrementing build numbers in Xcode was 2008-12 for Leopard / Xcode 3.x!

Build configuration files are a lot cleaner in source commits (vs project.pbxproj) especially if they are high change like build numbers. You can also include other xcconfig files eg #include "versions.xcconfig" for further separation. Not modifying project.pbxproj provides more flexibility for auto incrementing build numbers in a Run Script Phase.

I completely agree. I played with the build configuration files yesterday and that's absolutely the way to go.

Again, I really appreciate your responses - I'd blown so much time stuck on this and you instantly got me past it.

What do Xcode Project Versioning settings do?
 
 
Q