开发者

Xcode 4: Why can't I add a header file to a unit test target?

开发者 https://www.devze.com 2023-04-04 06:21 出处:网络
I have a basic Cocoa project open in Xcode including a unit test target. I created a new test cla开发者_运维问答ss to test one of my model classes. However, I can\'t add the header of the class I nee

I have a basic Cocoa project open in Xcode including a unit test target.

I created a new test cla开发者_运维问答ss to test one of my model classes. However, I can't add the header of the class I need to test to the unit testing target. The checkbox under "Target Membership" is not clickable for the unit test target (it is for the main target).

Because I can't add the header file to the unit test target, Xcode won't autosuggest method names of the class under test.

Am I missing something? Shouldn't I be able to add header files to a unit testing target?


I'm not an Xcode expert, but in my project, none of the header files have any target memberships set, none of the checkboxes are clickable - you can only add the .m files, and header files are somehow magically included. You should be able to just import the header file at the top of the test file and have method autocomplete work - unless you're using some weird macros in those tests, because I've noticed that Xcode gets confused with autocomplete while you're inside a macro call. If that's the case, try if the autocomplete works outside any macros.

0

精彩评论

暂无评论...
验证码 换一张
取 消