Is there a way of grabbing the current scheme from a run script phase?
I've tried $(SCHEME_NAME)
but it doesn't exist.
I couldn't find an environment variable to use, so I had to develop a work around: write a scheme name to disk in the Build Pre-action and then read it back out in the Run Script phase.
For each scheme you're interested in go to Edit Scheme and add a script with the following code:
rm -rf ${INTERMEDIATES_OUTPUT_DIR}
mkdir -p ${INTERMEDIATES_OUTPUT_DIR}
echo MY_SCHEME_NAME > ${SCHEME_FILE}
Next, go to your build target's "Build Settings" and add two "User-Defined Settings":
INTERMEDIATES_OUTPUT_DIR=${PROJECT_DIR}/build/intermediates/${CONFIGURATION}/
SCHEME_FILE=${INTERMEDIATES_OUTPUT_DIR}current_scheme.txt
Open up your "Run script" and add this:
SCHEME_NAME=`cat ${SCHEME_FILE}`
Be sure to add the intermediates build directory to your .gitignore file.
Obviously you could simplify this a bit by hardcoding a file name but this is a bit more robust (and we have other stuff that ends up in the intermediates directory, too).
Simplest one is set 'User Defined' variable as per scheme and use it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With