在构建期间显示或记录预处理器宏
是否可以将 XCode 中的预处理器宏记录或打印到构建结果中?
我想在构建过程中查看当前定义的宏。
例如,如果我已将 DEBUG 和 TESTSERVER 定义为预处理器宏,则构建结果中应该有一些行,例如:
- Compile Class.m ....
- GenerateDSYMFile ....
- 使用的宏:DEBUG、TESTSERVER...
也许有可以在构建后执行的自定义 shell 脚本。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,我在 Apple 中找到了解决方案文档
只需在运行脚本构建阶段输入
echo $GCC_PREPROCESSOR_DEFINITIONS
即可。OK I found the solution in the Apple documentation
Just enter a
echo $GCC_PREPROCESSOR_DEFINITIONS
to the run script build phase.如果您将运行脚本添加到构建阶段并确保选中“在构建日志中显示环境变量”,它将为您打印出所有环境变量。运行脚本可以为空,您将获得为当前构建设置的所有环境变量的转储。您不会得到的是头文件中定义的宏。
要在项目构建后访问信息,请转到构建结果并展开“运行自定义 shell 脚本”部分以查看值。
如果您已设置预处理器定义,它将显示在类似这样的行
setenv GCC_PREPROCESSOR_DEFINITIONS "DEBUG=1 Debug=1"
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"