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 set开发者_StackOverflow社区ttings?
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");
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
You'll find the answer in Turning on 'DEBUG' macro value.
精彩评论