如何在 xcconfig 变量中附加值? [英] How to append values in xcconfig variables?

查看:27
本文介绍了如何在 xcconfig 变量中附加值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Xcode 和 .xcconfig 文件.我试图在预处理器定义中附加一些值,但我根本无法使其工作.

I'm using Xcode and .xcconfig files. I'm trying to append some values in the preprocessor definitions, but I simply can't make it work.

我尝试了以下(以及许多变体),但到目前为止没有运气:

I tried the following (as well as many variations of this), but no luck so far:

GCC_PREPROCESSOR_DEFINITIONS = '$(GCC_PREPROCESSOR_DEFINITIONS) NEW_VALUE'

NEW_VALUE 符号从不添加到预处理器定义中.

The NEW_VALUE symbol is simply never added to the preprocessor definitions.

有人成功将新值附加到 xcconfig 文件中的变量吗?

Does anyone had success appending new values to variables in xcconfig files?

推荐答案

由于此问题的其他答案中所述的原因,您无法轻松继承值.

For reasons stated in other answers to this question, you can't inherit values easily.

我建议在级联中定义您的设置.让我们假设 APP 是您的项目前缀,并简单地定义几个 CFLAGS:

I recommend defining your settings in cascade. Let's assume APP is your project prefix and make this simple defining only a few CFLAGS:

platform.xcconfig:

platform.xcconfig:

APP_PLATFORM_CFLAGS = -DMAS=1

project.xcconfig:

project.xcconfig:

#include "platform.xcconfig"
APP_PROJECT_CFLAGS = -DBETA=1

target-one.xcconfig:

target-one.xcconfig:

#include "project.xcconfig"
APP_TARGET_CFLAGS = -DSUPER_COOL=1
#include "merge.xcconfig"

target-two.xcconfig:

target-two.xcconfig:

#include "project.xcconfig"
APP_TARGET_CFLAGS = -DULTRA_COOL=1
#include "merge.xcconfig"

merge.xcconfig:

merge.xcconfig:

OTHER_CFLAGS = $(inherited) $(APP_PLATFORM_CFLAGS) $(APP_PROJECT_CFLAGS) $(APP_TARGET_CFLAGS)

然后,您将基于 target-xxx.xcconfig 构建每个目标构建配置.一个真正的项目将使用更复杂的设置,为项目使用一个配置文件,为目标使用不同的配置文件,但你明白了.

Then, you'll base each of your targets build configurations on target-xxx.xcconfig. A real project will use more complex setups, using a configuration file for the project and a different one for the target, but you get the idea.

另外,请记住,$(inherited) 指的是层次结构中的更高级别,而不是更早.例如,它在目标级别从项目级别继承.不确定这是否也适用于 Xcode 4.

Also, remember that $(inherited) refers to higher level in the hierarchy, not earlier. For instance, it inherits from Project level at Target level. Not sure if this apply to Xcode 4 too.

这是GTM,去那里了解更多.

This is a simplification of GTM, go there to learn more.

这篇关于如何在 xcconfig 变量中附加值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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