how do I specify the DEBUG definition in the project build settings?

馋奶兔 提交于 2019-12-10 23:38:55

问题


I'm trying to implement the logging approach at http://www.cimgf.com/2010/05/02/my-current-prefix-pch-file/ . I'm not sure how to complete the step:

Therefore the first line is a switch to see if we are in debug mode. I set this value in the build settings of my project. If you look under the “Preprocessor Macros” section you can set the DEBUG definition there.

This is to cater for a "#ifdef DEBUG" entry (I'm only giving first line) in your code.

QUESTION: How do I actually setup this DEBUG flag in the project setttings?

For example I've tried:

  • going to the Preprocessor Macros section
  • go to DEBUG line item
  • in the value put in "-DEBUG=1"
  • this doesn't seem to work - it complies and runs but noting comes out in the log when I have this line of code
DLog(@"testingg");

回答1:


If you are editing the build settings directly through the Xcode UI, the value is just DEBUG=1 (no -). It's just a space separated list of values if you have more than one.

I prefer to use xccongif files to manage my build settings, in which case you use the "Based On" drop down in the bottom right corner of the build settings to set which xcconfig file to use, and in the xcconfig file use the following setting (example shows setting a log level flag also):

GCC_PREPROCESSOR_DEFINITIONS = TTMAXLOGLEVEL=TTLOGLEVEL_INFO DEBUG=1



回答2:


You'll find the answer in Turning on 'DEBUG' macro value.



来源:https://stackoverflow.com/questions/5321731/how-do-i-specify-the-debug-definition-in-the-project-build-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!