I have an .xcconfig file that I want to access via the terminal to access variables in the file. Is there a command or is there some way to do this? For example I have a variable called Build_Code = 1234. How would I access that?
Is there a way to access variables inside of a .xcconfigfile from the terminal?
511 Views Asked by kelson_99 AtThere are 2 best solutions below
On
If it's part of an Xcode project, you can run xcodebuild -showBuildSettings to see a list of the system defaults, plus what is in the default target's config values with variables replaced by values). You can also pass -json to get the results as a json file. For an explicit file, you can use the -xcconfig <path> argument as well. If in a project, it shows that file, then the project. If standalone, it just shows the values in that file. Unfortunately, -json does not seem to work when using that option. You would still have to parse the result a bit, but those values are more normalized, with comments stripped, from the original xcconfig. includes are processed but variables are not replaced in the -xcconfig mode.
Create a script to read the value of a variable.
Ex: .xconfig
get_value.bash
VARIABLE\s*=\s*VALUE.tris to remove spaces around the value.<file>argument could be hard coded if you will only ever check.xconfigMany other solutions could be conceived, depending on the exact requirements, but this does the basic need you put in your question.