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
CURRENT_PROJECT_VERSION is defined in your project.pbxproj file, not Info.plist . To change it, use agvtool:
xcrun agvtool new-marketing-version "your.app.version"
xcrun agvtool new-version -all "your.build.number"
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.
Related
Since Xcode 13, there is no Info.plist by default. Instead, the common field are in the target’s Info tab, and build settings in the project editor. A separated Info.plist file is added to project only when there are additional fields.
When I run the following command to set MARKETING_VERSION on Jenkins
$ xcrun agvtool new-marketing-version 1.0.0
It doesn't have any effect on Info.plist file unless the key CFBundleShortVersionString exists. But every time I update field in target's Info tab, the Info.plist file seems to be regenerated again and CFBundleShortVersionString disappear.
Therefore, I'm wondering is there any suggestion about how to setting MARKETING_VERSION via command line or how to use agvtool in this case. Any suggestion would be appreciated!
Indeed, in Xcode 13 agvtool has trouble to update marketing version.
In order to "fix" it, set GENERATE_INFOPLIST_FILE to NO in Build settings. This will prevent Xcode to generate the Info.plist automatically. Then create your own Info.plist with the same values and it should works.
Maxime
I use agvtool to bump my build numbers. In my recently refactored Xcode 13.0 (13A233) project, but am getting a strange error:
Cannot find "Foo.xcodeproj/../NO"
E.g.
% agvtool next-version -all
Setting version of project Foo to:
108.
Also setting CFBundleVersion key (assuming it exists)
Updating CFBundleVersion in Info.plist(s)...
Updated CFBundleVersion in "Foo.xcodeproj/../Foo/Support files/Environments/QA/Info.plist" to 108
Updated CFBundleVersion in "Foo.xcodeproj/../FooKit/Info.plist" to 108
Updated CFBundleVersion in "Foo.xcodeproj/../FooTests/Info.plist" to 108
Cannot find "Foo.xcodeproj/../NO"
I only have those three targets, Foo, FooKit, and FooTests, but it is looking for another one called NO.
I have looked around and do not see any extraneous Info.plist files. I am guessing that there is something set to NO in .pbxproj or Info.plist which agvtool is incorrectly picking up as a potential target, but I have not figured where it is. How precisely does the -all option figure out which Info.plist files need updating?
My work-around was to set the “Bundle version” in my various Info.plist files to $(CURRENT_PROJECT_VERSION):
Then I don't need to use the -all optional at all. I simply:
% agvtool next-version
Setting version of project Foo to:
126.
The .plist files will grab the version from the target, rather than being specified individually in the respective files. This avoids the curious behavior/bug of the -all option.
I have created a simple OSX Command Line App project with Xcode 6.3, called Foo, and set the location of Foo to ~/Desktop. Building and running the project is fine. To be clear, the project path is ~/Desktop/Foo/Foo.xcodeproj.
If I move the project's containing directory ~/Desktop/Foo to, say ~/Desktop/tmp/Foo, open ~/Desktop/tmp/Foo/Foo.xcodeproj, and then build the project, I see that Xcode creates ~/Desktop/Foo/build/ and so on. It seems that Xcode is still using the old build path rather than the build directory that is relative to the project (~/Desktop/tmp/Foo/build/).
Why is this? I am using a typical installation of Xcode and have not modified any configuration of Xcode nor the project or its build settings. Xcode 5 definitely did not behave this way.
Yes, the project has been cleaned.
I can only attribute this to accumulated cruft after installing, removing, and updating Xcode to various 6.x betas over the past year.
After deleting Xcode configuration via defaults delete com.apple.dt.Xcode, things are behaving as expected.
When Compiling for iPhone Simulator with Xcode 4.2, if I place
"$(BUILT_PRODUCTS_DIR)"
in
Build Settings / Header search paths / Debug
and exit editing I can see it resolves to:
"build/Debug-iphoneos"
Where should this be on my system? I have looked in:
Library/Developer/Xcode/DerivedData/{Project Name}/Build
but I can't find a file called build that contains a folder called Debug-iphoneos.
On my system, compiling an OSX project, that resolves to an absolute path:
BUILT_PRODUCTS_DIR /Users/andy/Source/MyProject/build/Debug
There are so many Xcode build variables that I keep a text file with a sample list of them which I got from executing a custom build script and viewing the output within the log tab.
If your code is going into the Library folder, then that is hidden under Lion. You can unhide it from the command line (Terminal) using:
$ cd ~
$ chflags nohidden Library
You should then be able to see its content.
Another tip: I have a ~/tmp folder where I let temporary stuff accumulate and I have set my Xcode preferences to put DerivedData and Archives into that folder so I can:
delete it now and again (I don't like temporary stuff accumulating where I cannot control it).
see it for packaging pre-release Archived project to testers.
I want to set the Bundle Version in my plist. However, it appears that the value that is actually LOOKED at by finder to put the version when you look at more info is "bundle versions string, short" Editing this, however, requires opening the plist file, rather than just editing the "version" in the target settings.
Is there a way to either a) make the bundle version always equal the bundle version short, b) make finder look at the bundle version instead of the short string or c) make the short version appear in the edit target settings window?
Or, is there some better way I should be dealing with this?
thanks.
Yes, you can use ${VARIABLE} style macros the Info.plist file.
We make a user-defined setting in the project called APP_VERSION, and then use ${APP_VERSION} in the CFBundleGetInfoString (Get Info string), CFBundleShortVersionString (Bundle versions string, short) and CFBundleVersion (Bundle version) keys. At build time, the variable gets filled in with the correct version.
Watch out though because sometimes a clean build is necessary for Xcode to update the Info.plist file as it does not do dependency checking against the variables.