views:

104

answers:

2

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

A: 

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.

cdespinosa
A: 

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.

DougW
The technical answer to your last question is that drag and drop is done with iteration, while inspectors are bindings-based, and the inspectors only validate for arrays where all elements have a valid keypath for the setting. As for unit tests, you're right, iPhone Application unit testing requires you to add app sources to the target. Mac unit testing uses bundle injection and does not require the app's sources in the unit test target.
cdespinosa
Thanks for clarifying cdespinosa. I guess it makes sense from a functional standpoint, but I still think apple is sacrificing usability for technical correctness in this case. If I checked a folder for inclusion in a target, I would obviously not expect it to include things that can't be included, and to be smart about it. No fault with your point, just my gripe with apple. Thanks again.
DougW