Show or log preprocessor macros during build
Is it possible to log or print preprocessor macros in XCode t开发者_运维技巧o 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.
OK I found the solution in the Apple documentation
Just enter a echo $GCC_PREPROCESSOR_DEFINITIONS
to the run script build phase.
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"
精彩评论