xcode 目标成员资格灰显(已禁用)

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

Target Membership grayed out ( disabled )

iphoneobjective-cxcodetarget

提问by DougW

I'm trying to create a new unit test build target for my iphone app. The problem I'm running into is that my source code "group"'s Target Membership options are grayed out.

我正在尝试为我的 iphone 应用程序创建一个新的单元测试构建目标。我遇到的问题是我的源代码“组”的目标成员选项是灰色的。

I did delete the original "Classes" folder, and created new "SourceCode" folder with an actual disk structure (thanks xcode). I imported it as a group, not a folder. It added automatically to my standard build target's Compile Sources, but I can't add it or drag it into my new target.

我确实删除了原始的“Classes”文件夹,并创建了具有实际磁盘结构的新“SourceCode”文件夹(感谢 xcode)。我把它作为一个组导入,而不是一个文件夹。它自动添加到我的标准构建目标的编译源,但我无法添加它或将它拖到我的新目标中。

Any thoughts?

有什么想法吗?

alt text http://img.skitch.com/20100118-mhurmqc33ecaq4xq3y2e5k3hs4.jpg

替代文字 http://img.skitch.com/20100118-mhurmqc33ecaq4xq3y2e5k3hs4.jpg

采纳答案by DougW

cdespinosa's answer is on the right track, but not really correct. The sources actually dogo into the unit test target, but you only need to include the ones covered by tests.

cdespinosa 的答案是正确的,但并不完全正确。源实际上确实进入了单元测试目标,但您只需要包括测试覆盖的那些。

I figured it out, and the issue is actually that if a group contains any file that cannot be included (header files for example), the Info dialog is not smart enough to only deal with those files and just locks you out. You have to manually select each .m file, even if you want to include everything in the group. If you have a huge project, I would suggest making a "smart group" (as opposed to xcode's normal "dumb group"), which will let you filter only .m files.

我想通了,问题实际上是,如果一个组包含任何无法包含的文件(例如头文件),则“信息”对话框不够智能,无法仅处理这些文件并将您锁定。您必须手动选择每个 .m 文件,即使您想在组中包含所有内容。如果您有一个庞大的项目,我建议您创建一个“智能组”(而不是 xcode 的普通“哑组”),它可以让您仅过滤 .m 文件。

Why you ask? Why is xcode able to figure this out when you import a bunch of files, some of which cannot be included in the build, but unable to make the same distinction for existing files? Good question. Par for the xcode course, imo.

你为什么问?为什么当您导入一堆文件时 xcode 能够解决这个问题,其中一些文件无法包含在构建中,但无法对现有文件进行相同的区分?好问题。标准的 xcode 课程,imo。

回答by cdespinosa

First, your sources don't go into the Unit Test target. Only the unit test sources themselves should go in that target. Second, the Compile Sources build phase can't build a group, only individual files. So I'd disbelieve that even if your group is in the target, that it's in the right build phase or that it's sources will be compiled.

首先,您的源不会进入单元测试目标。只有单元测试源本身应该进入该目标。其次,Compile Sources 构建阶段不能构建一个组,只能构建单个文件。所以我不相信即使你的团队在目标中,它也处于正确的构建阶段,或者它的源代码将被编译。

Uncheck the target to remove the group from it, then select the source files and drag them onto the target.

取消选中目标以从中删除组,然后选择源文件并将它们拖到目标上。

回答by RickJansen

This happened to me with Xcode 10.2 and a rather old project. The cause for me was that in the target settings the item "Headers" was missing for the target in Build Phases. Click the +, and select "New Headers Phase". Now you can properly add the headers to the target.

这在 Xcode 10.2 和一个相当老的项目中发生在我身上。对我来说,原因是在目标设置中,构建阶段中的目标缺少“标题”项。单击 +,然后选择“新标题阶段”。现在您可以正确地将标题添加到目标。