Well, I spent about 5 hours trying to figure it out. Absolutely none of the past resolutions on Stackoverflow topics worked for me, so I hope someone can give me an answer, rather than a wild goose hunt.
Problem: I have an x-code project that requires unit testing of my custom classes. I am using X-Code 3.2.5 with iOS SDK 4.2. After several different ways, I cannot do my unit testing on custom classes. It works great with Apple examples.
Custom classes are simple subclassed NSObjects with trivial iVars. We will call the class "Snookie".
I have already tried several dubious resolutions, but would like to get an answer from someone who had the same problem, with an answer that makes sense.
Replication:
- Add MyAppTesting unit test object.
- In the "MyAppTesting Information" section, add MyApp as a direct dependency.
- Create a group called Tests.
- In the Tests section, add the CaseiveC Test Case class.
- In the new test case .h class, import Snookie.h and create iVar:
#import <SenTestingKit/SenTestingKit.h> #import <UIKit/UIKit.h> #import "Snookie.h" @interface SnookieTests : SenTestCase { Snookie *snookieObject; } @end
In the new test case, the class .m, alloc / init snookie looks like this:
Error:
"_OBJC_CLASS_$_Snookie", referenced from: Objc-class-ref-to-Snookie in SnookieTests.o Symbol(s) not found Collect2: Id returned 1 exit status
source share