I've been trying to find a way to access the scheme name from a Run Script build phase. I'm writing a CLI command that updates a user's Xcode project so I don't have the luxury of tinkering with the Xcode user interface. I have been using Cocoapod's Xcodeproj dependency to update the build settings.
The first port of call is Xcode's build settings environment variables which do not contain the scheme. See here: https://developer.apple.com/documentation/xcode/build-settings-reference
I thought I would be able to do it programmatically via Xcodeproj dependency, but it appears the environment variables it sets are for the run-time application, not the build settings environment variables. See here: https://www.rubydoc.info/gems/xcodeproj/Xcodeproj/XCScheme/EnvironmentVariables
Apple's documentation on schemes makes no suggestion for this predicament: https://developer.apple.com/documentation/xcode/customizing-the-build-schemes-for-a-project
QUESTION: I was wondering if anyone had any suggestions for obtaining the scheme name that is running from a Run Script build phase? Some setting I could apply programmatically using Xcodeproj or another tool to configure the project that could pull the scheme name as a value at build time?
I don't want to hardcode the value into the script as this would require generating multiple scripts in the build phases for each scheme.
A scheme isn't really a "thing"; it is merely a unification of several other aspects of the build operation. The particular aspect you probably want is the configuration, which is available as the CONFIGURATION
build environment variable. In a bash script, for example, you can include a line such as
if [ $CONFIGURATION = "MyWonderfulConfiguration" ]; then
You can create configurations in the Project editor, and you can tie each scheme to its own configuration in the Scheme editor.