Xcode variables

Viewed 132385

In Xcode, I know that you can get variables such as PROJECT_DIR to use in some situations, such as a run script build phase. I am wondering if it's possible to get the build type (i.e., Release or Debug). Any ideas?

3 Answers

They're not all documented. For example, you won't find ARCHIVE_PATH, MARKETING_VERSION (the version string set in Xcode) in Naaff's or smorgan's answer. These 2 are very common pieces of information someone would need! Here's a list of all of them I got: https://gist.github.com/ben-xD/c063b0ca2c33684de1eb379bb9d6405d

How I got them

I found the best way was to print them using set, I just wrote this including a method to list all the environment variables available.

Add this to your run script (either Archive post run script, or your build phases run script, etc.):

#!/bin/sh
exec > ${PROJECT_DIR}/environment_variables.log 2>&1
set

Look in environment_variables.log and you'll see them all.

Related