简体   繁体   English

xcodebuild ACTIVE_COMPILATION_CONDITIONS 不会覆盖目标的 ACTIVE_COMPILATION_CONDITIONS

[英]xcodebuild ACTIVE_COMPILATION_CONDITIONS does not override target's ACTIVE_COMPILATION_CONDITIONS

We are trying to use xcodebuild to build our frameworks, instead of using manual Xcode IDE running buttons.我们正在尝试使用 xcodebuild 来构建我们的框架,而不是使用手动 Xcode IDE 运行按钮。 The issue is that in our framework we use ACTIVE_COMPILATION_CONDITIONS, which have several values.问题是在我们的框架中我们使用 ACTIVE_COMPILATION_CONDITIONS,它有几个值。 Those values are then used to check at runtime if the particular framework is integrated, like checking for Sentry:然后使用这些值在运行时检查特定框架是否已集成,例如检查 Sentry:

#if SENTRY_AVAILABLE
    import Sentry
#endif

The problem is that, for some builds, we need to override our project settings, specifically ACTIVE_COMPILATION_CONDITIONS.问题是,对于某些构建,我们需要覆盖我们的项目设置,特别是 ACTIVE_COMPILATION_CONDITIONS。 However, after the following script successfully executes, the Xcode still does not override our provided ACTIVE_COMPILATION_CONDITIONS with defined in the project.但是,在以下脚本成功执行后,Xcode 仍然不会覆盖我们在项目中定义的 ACTIVE_COMPILATION_CONDITIONS。

The script:剧本:

xcodebuild -workspace project.xcworkspace -scheme SDKNR1 ONLY_ACTIVE_ARCH=NO 
EXCLUDED_ARCHS=arm64 ACTIVE_COMPILATION_CONDITIONS=SENTRY_AVAILABLE -configuration 
release -derivedDataPath $PROJECT_DIR/../simulators/SDKNR1 -sdk iphonesimulator
ENABLE_BITCODE=YES BITCODE_GENERATION_MODE=bitcode OTHER_CFLAGS="-fembed-bitcode" clean build

As you can see we define ACTIVE_COMPILATION_CONDITIONS=SENTRY_AVAILABLE, however it will not override target's (SDKNR1) project settings.如您所见,我们定义了 ACTIVE_COMPILATION_CONDITIONS=SENTRY_AVAILABLE,但它不会覆盖目标 (SDKNR1) 的项目设置。 Suppose, SDKNR1 does not have any ACTIVE_COMPILATION_CONDITIONS.假设,SDKNR1 没有任何 ACTIVE_COMPILATION_CONDITIONS。 We expected that xcodebuild command would override target's ACTIVE_COMPILATION_CONDITIONS and would include SENTRY_AVAILABLE我们预计 xcodebuild 命令会覆盖目标的 ACTIVE_COMPILATION_CONDITIONS并包含 SENTRY_AVAILABLE

Would welcome any ideas, or perhaps it is not possible?欢迎任何想法,或者也许这是不可能的?

The proper build setting key is "SWIFT_ACTIVE_COMPILATION_CONDITIONS"正确的构建设置键是“SWIFT_ACTIVE_COMPILATION_CONDITIONS”

You can double check this by using the command and verifying the key exists:您可以通过使用该命令并验证密钥是否存在来仔细检查:

xcodebuild -showBuildSettings <project/scheme/target/configuration flags>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM