在 Xcode 中切换构建配置时链接的静态库变为红色是什么意思?

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

In Xcode What does it mean when a linked static library turns red when switching build configurations?

iphonecocoacocoa-touchxcode

提问by Corey Floyd

I think the title is pretty clear. I have ran into this twice now.

我认为标题很清楚。我现在已经遇到过两次了。

The first time it indicated a problem, and my project wouldn't compile. The second time everything still worked.

第一次表明有问题,我的项目无法编译。第二次一切仍然有效。

Is it just a fluke if my code still builds when this turns red?

如果我的代码在变成红色时仍然构建,这只是侥幸吗?

回答by danielpunkass

Anything in the files and groups list that turns red indicates a missing file or directory. This is not necessarily cause for concern, because in many instances the file is expected to be built as part of your build process.

文件和组列表中变为红色的任何内容都表示缺少文件或目录。这不一定值得关注,因为在许多情况下,文件应该作为构建过程的一部分来构建。

In the case of your linked static library, you are probably depending on a second target or project to build the static library. When you changed build configurations, Xcode noticed that it had not yet been built, so it shows it as red. When you built the project and the dependent library was itself built, it turned black again.

对于链接的静态库,您可能依赖第二个目标或项目来构建静态库。当您更改构建配置时,Xcode 注意到它尚未构建,因此将其显示为红色。当你构建项目并且依赖库本身构建时,它再次变黑。

回答by smorgan

The first time it indicated a problem, and my project wouldn't compile. The second time everything still worked.

第一次表明有问题,我的项目无法编译。第二次一切仍然有效。

That suggests that you don't have your build dependencies set up correctly, which will bite you every time you do a clean build. You need to make the target(s) that need the static library have an explicit build dependency on the target that builds that library.

这表明您没有正确设置构建依赖项,这会在您每次进行干净构建时咬你。您需要使需要静态库的目标对构建该库的目标具有显式构建依赖关系。