Goal: To set my target’s "Current Project Version" to $(CURRENT_PROJECT_VERSION)
so that changing the project’s info.plist’s Bundle Version
variable will automatically carry over to the project file.
How I am doing it: I am using a script to change my project’s info.plist’s CFBundleVersion
using PlistBuddy. Because I want this change to be automatically reflected in the project file, I have set the target’s "Current Project Version" to $(CURRENT_PROJECT_VERSION)
. My understanding is that this is just a pointer to the CFBundleVersion
from the project’s info.plist.
The problem: Although the script runs correctly (i.e., the Bundle Version
variable in the info.plist is updated), the "Current Project Version" never updates, and in fact it displays an empty field instead.
Why is this not working?
Note that I am explicitly trying to do this without using fastlane or agvtool
2
Answers
CURRENT_PROJECT_VERSION
is defined in your project.pbxproj file, not Info.plist . To change it, use agvtool:Or you can use fastlane increment_version_number.
The plist is generated from the project file, not the other way around. The plist is (usually) generated every time xcode builds your application, so for most people it is a transient file. If you change your project file’s version, then the plist file will stay in sync.
Note that you can use PlistBuddy on an Xcode project file, but since it’s a bunch of Guids, you have to query your way through the file to get all of the BuildConfigurations that you need to update.
Or, you can use .xcconfig files which will make it much easier to modify the version which Xcode will read in to modify project settings, and then push that into the .plist.