3

I am trying to get the current scheme name and set it as a value in my plist. I am running the following shells script:

/usr/libexec/PlistBuddy -c "Set :SchemeName \"$SCHEME_NAME\"" "$INFOPLIST_FILE"

The result is that the scheme name is an empty string. If i set some constant string it works perfectly. How can i get the current scheme name?

1
  • You can get it in pre-action scripts in product > edit scheme Commented Jun 30, 2022 at 10:40

2 Answers 2

7

You can't.

From https://developer.apple.com/library/ios/featuredarticles/XcodeConcepts/Concept-Schemes.html:

An Xcode scheme defines a collection of targets to build, a configuration to use when building, and a collection of tests to execute.

So this is purely an Xcode interface feature, and it's not part of the build process.

If you want to know for which build configuration (eg. Debug or Release) you're compiling for though, you can use $CONFIGURATION.

Sign up to request clarification or add additional context in comments.

Comments

0

It seems the scheme name isn't available in the build phase scripts.

You have $CONFIGURATION environment variable, but that is just the build configuration (set in Edit scheme > Info), e.g. Debug or Release. But many schemes can have the same build configuration.

It might suit you to create a new build configuration just for a specific scheme, duplicated from an existing build configuration. I did this when I had a Staging scheme which needed specific tweaks in my custom build-phase script.

How to create a new build configuration...

  • Select your project in the XCode navigator (the main left hand pane that looks like a file tree).
  • Select your project in the little pane that shows you your project and its targets. If you've selected a target you can't add a configuration.
  • Tap the Info tab > Configurations > + button and pick a configuration to duplicate.

Once you have that you can go edit your scheme and change its build configuration to the new one. Then your scripts will know it's using that scheme.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.