Xcode 4:项目不支持工作区中的 $(inherited) 构建设置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13327744/
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-15 02:03:47  来源:igfitidea点击:

Xcode 4: Project does not honor $(inherited) Build Setting in Workspace?

xcodexcode4build-processdependency-managementtargets

提问by jww

Today is my day to suffer through Xcode 4, Workspaces, and Projects.

今天是我饱受 Xcode 4、工作区和项目困扰的一天。

I have a workspacewith a few open source libraries (openssl, sqlcipher, and a couple of others). Within the workspace there is one "Main" projectwhich produces an EXE as a target. The open source projects are "subprojects" or "child projects" to the "Main" project. It looks similar to below:

我有一个工作区的几个开源库(OpenSSL的,sqlcipher,和其他几个)。在工作区中有一个“主”项目,它生成一个 EXE 作为目标。开源项目是“主”项目的“子项目”或“子项目”。它看起来类似于下图:

Main Project
  +- OpenSSL Project
  +- SqlCipher Project
  ...

In the "Main" project, under "Project" (rather than "Target"), I set preprocessor and warning flags build settings. For example, the debug preprocessor macros are "DEBUG=1 SQLITE_DEBUG=1 SQLITE_HAS_CODEC=1" (without the quotes). Conversely, release preprocessor macros is set to "NDEBUG=1 NS_BLOCK_ASSERTIONS=1 SQLITE_HAS_CODEC=1".

在“主”项目中,在“项目”(而不是“目标”)下,我设置了预处理器和警告标志构建设置。例如,调试预处理器宏是“DEBUG=1 SQLITE_DEBUG=1 SQLITE_HAS_CODEC=1”(不带引号)。相反,发布预处理器宏设置为“NDEBUG=1 NS_BLOCK_ASSERTIONS=1 SQLITE_HAS_CODEC=1”。

In the Main "Target" (not "Project") and all subprojects (both "Project" and "Targets"), I ensure there are no project-specific build setting overrides (by highlighting "Preprocessor Macros" and pressing COMMAND+DELETE). I then ensure the field is set to "$(inherited)" (without the quotes).

在主“目标”(不是“项目”)和所有子项目(“项目”和“目标”)中,我确保没有特定于项目的构建设置覆盖(通过突出显示“预处理器宏”并按 COMMAND+DELETE) . 然后我确保该字段设置为“$(inherited)”(不带引号)。

Lo and behold, the child projects do not honor "$(inherited)". When I look at the command line issued by Xcode, nothing is present that should be present from GCC_PREPROCESSOR_DEFINITIONS. For example, the SqlCipher's project files are not compiled with the inherited build settings from Main.

瞧,子项目不尊重“$(继承)”。当我查看 Xcode 发出的命令行时,GCC_PREPROCESSOR_DEFINITIONS 中不存在任何应该存在的内容。例如,SqlCipher 的项目文件不是使用从 Main 继承的构建设置编译的。

I thought the problem might be similar to Preprocessor Macros ignored in XCode's project settings, but not target settings, but I can't seem to get the same [positive] results.

我认为问题可能类似于在 XCode 的项目设置中忽略的预处理器宏,但不是目标设置,但我似乎无法获得相同的 [positive] 结果。

Could anyone explain to me how to get child projects to honor "$(inherited)"? As I try to read through Apple's documentation, I only get more confused by what I read and the behavior I observe. Please explain it as if you were talking to a child.

谁能向我解释如何让子项目兑现“$(继承)”?当我尝试通读 Apple 的文档时,我只会对我阅读的内容和我观察到的行为感到更加困惑。请像在和孩子说话一样解释它。

回答by justin

These settings don't cross project boundaries. I recommend you configure your targets using .xcconfigfiles instead (these may be referenced by multiple projects).

这些设置不会跨越项目边界。我建议您使用.xcconfig文件来配置目标(这些文件可能会被多个项目引用)。



Update/Explanation:Using your example setup: The build settings for Main Project may affect any of Main Project's targets, but they won't cross over to OpenSSL Project's targets.

更新/说明:使用您的示例设置:主项目的构建设置可能会影响主项目的任何目标,但它们不会跨越 OpenSSL 项目的目标。