I want to write some logic unit tests for classes in my XCode application. In Xcode 4, I clicked on the project name in the Project Navigator, and from the bottom clicked Add Target. I chose "Cocoa Touch Unit Testing Bundle" under Other, give the new target a "product name" of "tests", and finish.
Because the class I want to test is compiled as part of my existing application target, for my new "tests" target I immediately go to the Build Phases tab and add my existing application target as the only target dependency.
I then go to the created tests.m file, import the class I want to test (below it's ReleasePlanManager
, and call one of its methods. But the linker fails with an error like:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_ReleasePlanManager", referenced from:
objc-class-ref in tests.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
So the class cannot be found, even though (from my understanding) adding the application target (which it is a part of) should be sufficient?
Any help would be greatly appreciated. Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…