Get current Scheme Name from Run Script Phase
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.