Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show or log preprocessor macros during build

Is it possible to log or print preprocessor macros in XCode to the build results?

I want to see the current defined macros during a build.

For example if I have defined DEBUG and TESTSERVER as preprocessor macro there should be some lines in the build results like:

  • Compile Class.m ....
  • GenerateDSYMFile .....
  • Used macros: DEBUG, TESTSERVER...

Maybe there is custom shell script that could be executed after build.

like image 684
AlexVogel Avatar asked Nov 18 '25 22:11

AlexVogel


2 Answers

OK I found the solution in the Apple documentation

Just enter a echo $GCC_PREPROCESSOR_DEFINITIONS to the run script build phase.

like image 134
AlexVogel Avatar answered Nov 21 '25 13:11

AlexVogel


If you add a Run Script to the build phase and make sure "Show environment variables in build log" is checked it will print out all the environment variables for you. The run script can be empty and you will get a dump of all of the environment variables set for that current build. What you will not get is macros defined in header files.

To access the information once your project is built go to build results and expand the section "Run custom shell script " to view the values.

If you have set up Preprocessor definitions it will show on a line like this

setenv GCC_PREPROCESSOR_DEFINITIONS "DEBUG=1 Debug=1"

like image 29
Joe Avatar answered Nov 21 '25 12:11

Joe