A collection of utilities to work with Xcode files. Currently there are two products in this SPM project.
A reusable lib to work with xcodeproj files. Specifically the lib allows easy parsing of pbxproj and xcconfig files. Schemes are not supported (yet).
Example of use:
let xcodeproj = try XcodeProj(autodetectInFolderAtPath: "/path/to/project/")
try xcodeproj.iterateCombinedBuildSettingsOfTargets{ target, targetName, configurationName, combinedBuildSettings in
print("\(targetName) - \(configurationName)")
/* The line below returns the resolved value of the MARKETING_VERSION build
* setting. All the rules I’m aware of (Xcode 12 beta 6) are followed,
* including but not limited to:
* - Thorough xcconfig files parsing;
* - Embedded variables like so “$(VALUE_$(VARIANT))”;
* - Resolution of variable depending on build config levels (project config, then targets);
* - Other… */
print(combinedBuildSettings["MARKETING_VERSION"])
}
Note: Parsing the parameters in a build configuration (e.g. FOO[sdk=macosx*]
) is supported,
however the resolution of the variables do not take the parameters in account yet.
Other Note: I use the post-Xcode 10 variable resolution to resolve variables.
You might see a difference in the values XcodeProj
computes and the ones Xcode shows in the GUI editor.
That is expected; the GUI seems to still use the pre-Xcode 10 algorithm to resolve its variables.
You should however get the same values than XcodeProj
at build time, if you don’t please file an issue!
You can check whether the values are the same by adding a key in your Info.plist
file with the value set to $(VAR_TO_CHECK)
and checking the values in the plist at runtime.
See https://stackoverflow.com/a/50731052 for more info about Xcode variable resolutions.