问题描述
在我的代码中,我想有条件地执行一些操作:
In my code, I want to conditionally perform a few operations with:
#ifdef DEBUG
NSLog(@"I'm in debug mode");
#endif
我已经配置了Project-> Edit Project Settings-> Build tab so 'DEBUG'被列为用户定义的设置,其值为1.在Configuration下拉列表中选择Debug。这仍然没有打开Debug构建的指令,虽然我认为它会做什么。
I've configured Project->Edit Project Settings->Build tab so that 'DEBUG' is listed as a User-Defined setting with a value of 1. Debug is selected in the Configuration dropdown. This still doesn't turn on the directive for the Debug build although I thought that's what it would do.
在构建阶段我还需要做什么才能允许为此?
What else do I need to do during the build stage to allow for this?
推荐答案
您需要为此设置编译器标志。
You need to set a compiler flag for that.
要执行此操作,请在目标上获取信息,确保已选择调试配置(而不是所有配置),并查找其他C标志和其他C ++标志(在Xcode 3.1中,这些在 GCC 4.2 - 语言下)。
To do it, Get Info on the target, make sure you have selected the Debug configuration (and not All Configurations), and look for Other C Flags and Other C++ Flags (in Xcode 3.1 these are under GCC 4.2 - Language).
然后将以下内容添加为值: -DDEBUG
两者。
Then add the following as a value: -DDEBUG
for both.
这将定义预编译器的DEBUG来获取它。
This will define the DEBUG for the precompiler to pick it up.
这篇关于打开'DEBUG'宏观值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!