Reputation: 30035
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
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.
Build Phases
tab/sectionCopy Bundle Resources
+
as seen belowCopy Bundle Resources
group OR select the target from the file explorer tab.Upvotes: 0
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
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
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