我如何添加一个#IFDEF DEBUG于X code? [英] How can I add an #ifdef DEBUG to Xcode?
问题描述
我有哪些不应该在发布版本中使用的项目的一些code,但测试时是很有用的。我想要做这样的事情:
I have some code in a project which should never be used in the release build, but is useful when testing. I'd like to do something like this:
#ifdef DEBUG
// Run my debugging only code
#endif
我在哪里可以加在X $ C $的C 4的DEBUG设置?我试图把它在编辑计划下运行MyApp->传递上启动参数,但没有奏效。另外,有一个标志,已经可以为这个?
Where do I add the DEBUG setting in Xcode 4? I tried putting it in the "Edit Scheme" under Run MyApp->Arguments Passed On Launch, but it didn't work. Alternatively, is there a flag already available for this?
推荐答案
在最近的X code ++项目模板已经有一个 DEBUG = 1
为调试定义的宏构建配置(在 preprocessor宏的部分)。您可以使用#如果
preprocessor指令进行测试。
In recent Xcode project templates there’s already a DEBUG=1
macro defined for the Debug build configuration (in the Preprocessor Macros section). You can test it using the #if
preprocessor directive.
这篇关于我如何添加一个#IFDEF DEBUG于X code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!