printing shell variables from xcode build

Sometimes while writing scripts for use in a target’s Build Phase I need to find out what enviroment variables are set to at build time. The simplest way I’ve found to do this is to create a new Run Script Phase in the targets Build Phase and add this to it

printenv > ~/Desktop/enviromentVars.txt

The next time you build the target it will create a text file in your Desktop directory with all the enviroment vars for that scheme.