11

I have an app which was setting versions automatically when I incremented from

XCode > General > Version.

But recently I have updated XCode to 11.0 and seems the script is not working as expected:

version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" $SRCROOT/MyApp/Info.plist`
version+=" ("
version+=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" $SRCROOT/MyApp/Info.plist`
version+=")"
/usr/libexec/PlistBuddy "$SRCROOT/MyApp/Settings.bundle/Root.plist" -c "set PreferenceSpecifiers:1:DefaultValue $version"

Above script suppose to automatically update version and would have been visible in Settings > App.

enter image description here

But the question is there any change need to be done for this script to make automatically update version number from XCode?

Currently it is being replaced by scripts as $(MARKETING_VERSION) when version is incremented from XCode > General > Version which is not correct.

Nagarjun
  • 6,557
  • 5
  • 33
  • 51

2 Answers2

10

The version string $MARKETING_VERSION as well as build number $CURRENT_PROJECT_VERSION are now exposed as environment variable during the build process as they are now persisted in the .pbxproj configuration.

You should be able to achieve what you want like this:

version="$MARKETING_VERSION ($CURRENT_PROJECT_VERSION)"
/usr/libexec/PlistBuddy "$SRCROOT/MyApp/Settings.bundle/Root.plist" -c "set PreferenceSpecifiers:1:DefaultValue $version"
dgimb
  • 126
  • 5
  • $CURRENT_PROJECT_VERSION do not display anything. However version is displayed in $MARKETING_VERSION. – Nagarjun Oct 26 '19 at 09:04
2

It worked by displaying MARKETING_VERSION itself: Thanks @dgimb and @Mojtaba Hosseini for your answers.

version="$MARKETING_VERSION"
version+=" ("
version+=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" $SRCROOT/MyApp/Info.plist`
version+=")"

/usr/libexec/PlistBuddy "$SRCROOT/MyApp/Settings.bundle/Root.plist" -c "set PreferenceSpecifiers:1:DefaultValue $version"
Nagarjun
  • 6,557
  • 5
  • 33
  • 51