如何在项目构建设置中指定DEBUG定义? [英] how do I specify the DEBUG definition in the project build settings?

查看:47
本文介绍了如何在项目构建设置中指定DEBUG定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 http://www.cimgf.com/2010/05/02/my-current-prefix-pch-file/.我不确定如何完成此步骤:

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:

因此第一行是一个开关看看我们是否处于调试模式.我设置这个值在我的构建设置中项目.如果你看下您可以在预处理器宏"部分中在此处设置DEBUG定义.

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.

这是为了在您的代码中提供一个"#ifdef DEBUG"条目(我只提供第一行).

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?

例如,我尝试过:

  • 转到预处理器宏"部分
  • 转到DEBUG订单项
  • 输入"-DEBUG = 1"中的值
  • 这似乎不起作用-它符合要求并且可以运行,但是请注意,当我有这行代码时,就会出现在日志中
DLog(@"testingg");

推荐答案

如果直接通过Xcode UI编辑构建设置,则该值仅为DEBUG = 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.

我更喜欢使用xccongif文件来管理我的构建设置,在这种情况下,您可以使用构建设置右下角的基于"下拉列表来设置要使用的xcconfig文件以及在使用的xcconfig文件中以下设置(示例还显示了设置日志级别标志):

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

这篇关于如何在项目构建设置中指定DEBUG定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆