问题
Since version 11, Xcode sets my CFBundleVersion
value to $(CURRENT_PROJECT_VERSION)
and my CFBundleShortVersionString
to value $(MARKETING_VERSION)
whenever I enter Version or Build values in the target settings (tab "General").
The actual version and build values that I enter are now stored in the project.pbxproj file. I do not want or like this behaviour, as I use shell scripts to modify the values at buildtime.
I can manually set the correct values in the Info.plist file, but as soon as I change Version or Build numbers in the target settings, the Info.plist file gets changed again by Xcode.
How do I stop Xcode 11 from doing this?
When I modify my build script to change the project file itself, Xcode will immediately cancel the build as soon as the project file is changed.
回答1:
Don't.
Presumably there is a reason why this behavior changed. If later Xcode features build on this behavior, things get more and more "constructed" down the line.
Instead of trying to bend Xcode, change how the build script retrieves these values:
How to read current app version in Xcode 11 with script
If you need to manipulate the project.pbxproj
file, it is a Next style plist that is well documented. You can use plistbuddy
which is compatible with this old format. You can also use awk
with more scripting if you have more complex manipulations.
If I understand your use case, you could write a script that gets the highest version numbers with awk
and then updates all lower version numbers it can find in the file with sed
.
来源:https://stackoverflow.com/questions/58235419/how-to-stop-xcode-11-from-changing-cfbundleversion-and-cfbundleshortversionstrin