What Values Should I Use for Cfbundleversion and Cfbundleshortversionstring

What values should I use for CFBundleVersion and CFBundleShortVersionString?

Think of it this way: The "short version" (CFBundleShortVersionString) is the public version number. The "version" (CFBundleVersion) is more of an internal version number that could change far more frequently than the public "short version". Personally I use the same for both but many people update the "version" on every build. Either way you typically update the "short version" when you release to Apple. How often you update the "version" is up to you and your needs.

Difference between Xcode version (CFBundleShortVersionString) and build (CFBundleVersion)

The Apple document "Information Property List Key Reference" says that CFBundleShortVersionString represents a release version, whereas CFBundleVersion represents any build, released or not. Also, CFBundleShortVersionString can be localized, though I don't know why you'd want to, since they say it is supposed to be "a string comprised of three period-separated integers". For a release build, it would be reasonable to make the two numbers the same. For a development build, you might tack something else on to the CFBundleVersion, maybe another dot and integer.

iOS: How to upgrade my CFBundleVersion and my CFBundleShortVersionString automatically in Xcode 11? (My old script doesn't work anymore)

Here is the complete script. I tried it with old and new projects.

 #!/bin/bash
rm -rf build

Build=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
Version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE")

if [ "${Build}" = "" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion 1" "$INFOPLIST_FILE"
else
Build=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
Build=$(echo "scale=0; $Build + 1" | bc)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $Build" "$INFOPLIST_FILE"
fi
if [ "${Version}" = "" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString 1.00" "$INFOPLIST_FILE"
else
Version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE")
Version=$(echo "scale=2; $Version + 0.01" | bc)
if [ "${CONFIGURATION}" = "Release" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $Version" "$INFOPLIST_FILE"
fi
fi

EDIT:

For completing the solution, I added that keys in the plist. I changed the existing values by:

<key>CFBundleShortVersionString</key>
<string>1.00</string>
<key>CFBundleVersion</key>
<string>1</string>

Is it correct that different versions of a submitted app are compared using CFBundleVersion

The reports from users seem to be inconsistent. Also, the SO answers are more than 2 years old.

The section about "configuring your app" in Apple's App Distribution Guide says this:

Setting the Version Number and Build String

The version number is a two-period-separated list of positive integers, as in 4.5.2. The first
integer represents a major revision, the second a minor revision, and
the third a maintenance release. The version number is shown in the
store and that version should match the version number you enter later
in iTunes Connect. For details on possible values, see
“CFBundleShortVersionString” in Information Property List Key
Reference.

The build string represents an iteration (released or unreleased) of
the bundle and can contain a mix of characters and numbers, as in
12E123. For Mac apps, the user can click the version number in the
About window to toggle between the version number and the build
string. For details on possible values, see “CFBundleVersion” in
Information Property List Key Reference.

For iOS apps, update the build string whenever you distribute a new
build of your app for testing. iTunes will recognize that the build
string changed and properly sync the new iOS App Store Package to the
device. For how to configure your app for testing, read “Beta Testing
Your iOS App.”

This indicates that for the App Store what matters is CFBundleShortVersionString and it should match the value in iTunes connect. And that changes to CFBundleVersion are considered when differentiating between builds for testing.

However, this somehow contradicts what "Information Property List Key Reference" says about CFBundleVersion

CFBundleVersion (String - iOS, OS X) specifies the build version
number of the bundle, which identifies an iteration (released or
unreleased) of the bundle. The build version number should be a string
comprised of three non-negative, period-separated integers with the
first integer being greater than zero. The string should only contain
numeric (0-9) and period (.) characters. Leading zeros are truncated
from each integer and will be ignored (that is, 1.02.3 is equivalent
to 1.2.3). This key is not localizable.

It isn't the first time or the last that Apple's docs have contradicting information.

Personally, I'd go with the App Distribution Guide guidelines but setting the same version number for both values seem to comply with both documentations, so you should be ok.

For my Mac OSX app, I am using a dotted version in CFBundleShortVersionString and a running integer (that corresponds to my SCM revision number) in CFBundleVersion. Submitting updates like that for years and never had a problem

How to set CFBundleVersion (and/or) CFBundleShortVersionString programmatically?

You could use agvtool to update build number.
e.g:
agvtool new-version -all 3.0.0

What's the difference between version number in iTunes Connect, bundle version, bundle version string in Xcode?

Yes, they are related. They all refer to the version of your application.

  • iTunes Connect
    This is the version number shown in the App Store; This must be a pure version number like 1.2.3

  • Bundle Version (CFBundleVersion)
    This doesn't need to be a pure version number. This can be something like 12345 or 1.2.3 (Build 12345AB). This is shown in the About window for Mac OS X apps for example and is often more a "Build Number" than a "Version Number".

  • Bundle Version String (CFBundleShortVersionString)
    This value is used as the "real" version number. This must be the same string as used for the version in iTunes Connect.

Update:
As pointed out by @snlehton, the CFBundleVersion has to be a pure version number like 1.2.3 when you want to upload your application to the (iOS) App Store.

CFBundleVersion must be higher than previous version

It turns out that I had some problem in my original submission which caused the user-visible version to be "1.0" but the internal bundle version to be "1.2". So I changed my new version to be 1.3 and 1.3 and the submission worked.

enter image description here



Related Topics



Leave a reply



Submit