DougW
DougW

Reputation: 30035

Target Membership grayed out ( disabled )

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.

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.

Any thoughts?

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

Upvotes: 11

Views: 9740

Answers (4)

Nickofthyme
Nickofthyme

Reputation: 4327

For me this was happening for audio files, even selecting the target while importing would be ignored. I was able to fix this by adding the Copy Bundle Resources in the Build Phases section of your project.

  1. Click your top-level app
  2. Go to the Build Phases tab/section
  3. Make sure you see a group called Copy Bundle Resources
  4. If you don't see this group add it with the + as seen below
  5. With this added, you can now drag files directly into this Copy Bundle Resources group OR select the target from the file explorer tab.

enter image description here

Upvotes: 0

RickJansen
RickJansen

Reputation: 1713

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.

Upvotes: 11

DougW
DougW

Reputation: 30035

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

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.

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.

Upvotes: 1

cdespinosa
cdespinosa

Reputation: 20799

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.

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

Upvotes: 1

Related Questions