Xcode:为不同的构建配置设置 GCC_PREPROCESSOR_DEFINITIONS?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1540322/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:53:28  来源:igfitidea点击:

Xcode: Setting GCC_PREPROCESSOR_DEFINITIONS for different build configurations?

iphonexcodebuildpreprocessor

提问by Greg Maletic

I want to set GCC_PREPROCESSOR_DEFINITIONSfor each of my four build configurations (Debug, Release, Ad Hoc, and Distribution.) I'd like to have a different setting for each.

我想为GCC_PREPROCESSOR_DEFINITIONS我的四个构建配置(调试、发布、Ad Hoc 和分发)中的每一个进行设置。我想为每个配置设置不同的设置。

The screen I'm looking at is the Target Info window's "Build" tab. When I set the Configuration pop-up to "Debug" I can see my GCC_PREPROCESSOR_DEFINITIONSsetting there. When I switch to "Release," or any of the other configurations, it's no longer visible. Yet when I try to add it to those configurations, it says GCC_PREPROCESSOR_DEFINITIONSalready exists, and that I can't add it again.

我正在查看的屏幕是“目标信息”窗口的“构建”选项卡。当我将配置弹出窗口设置为“调试”时,我可以GCC_PREPROCESSOR_DEFINITIONS在那里看到我的设置。当我切换到“发布”或任何其他配置时,它不再可见。然而,当我尝试将它添加到这些配置时,它说GCC_PREPROCESSOR_DEFINITIONS已经存在,而且我无法再次添加它。

As I said, I want to have a different setting for my various builds. How can I accomplish this?

正如我所说,我想为我的各种构建设置不同的设置。我怎样才能做到这一点?

Thanks very much.

非常感谢。

回答by Cory Kilger

Make sure there isn't a setting called "Preprocessor Macros". This is the same as GCC_PREPROCESSOR_DEFINITIONS.

确保没有名为“预处理器宏”的设置。这与GCC_PREPROCESSOR_DEFINITIONS.

回答by jazzcat

OTHER_CFLAGS if I understood the question right. And pass your defines like -DDEBUGor something.

OTHER_CFLAGS 如果我理解正确的话。并传递您的定义之类的-DDEBUG东西。

And yes, if you need to assign a value to a macro, you could do something like this - '-DSOME_MESSAGE=@"Hello, World!"'. Note ' symbols around - they are required. SOME_MESSAGE macro will be defined with @"Hello, World!" value.

是的,如果您需要为宏分配一个值,您可以执行以下操作 - '-DSOME_MESSAGE=@"Hello, World!"'。注意 ' 周围的符号 - 它们是必需的。SOME_MESSAGE 宏将用@"Hello, World!" 定义。价值。