How to access Xcode environment variables (and build) from an external script?

I am writing a script to automate my iOS building. It will run outside of Xcode, either through a terminal or from build automation software. Is there a way to access the Xcode environment variables in my script, so I don’t have to try to output them myself?

For example, can I access PROJECT_DIR instead of assuming I'm in the current directory and running pwd?

I am currently hard-coded product names for different build configurations. (I also hardcode the assembly configuration, but I could parse them with xcodebuild -list.) Is there a way to get the application if you know the assembly configuration name?

(I saw this related question , but I have no answer for me.)

+5
source share
1 answer

Xcode environment variables are defined only for child processes of the command line tool xcodebuild.

One solution I used is a very simple script as part of my build process (Project-> New Build Phase-> Add Run script Build Phase). All this script is exporting the necessary variables and calling the script in my path somewhere.

That the script can be generated by your build script before calling xcodebuildand voilà! you have an external script that has access to the Xcode build variables.

+10

All Articles