Reputation: 449
I am trying to set up application tests for my iOS application. I am using the following article as the basis of what I am doing: http://cocoawithlove.com/2009/12/sample-iphone-application-with-complete.html
So I can created the additional targets that I need. I now have 3 targets: -The original target -The tests target -The duplicate target
I have added the original target as a target dependency to my test target. I have then added the test target as a target dependency on my duplicate target.
However, whenever I try to reference any of my classes in my test cases I get:
Undefined symbols for architecture armv7: "_OBJC_CLASS_$_MyClass", referenced from: objc-class-ref in MyApplicationTests.o "_OBJC_CLASS_$_AnotherClass", referenced from: objc-class-ref in MyApplicationTests.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is there another location which I need to set up some sort of dependency to tell my Tests target that it is dependant on the original target?
Cheers
Upvotes: 1
Views: 1713
Reputation: 449
So I found the solution to this issue at: http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/
You need to do the following to avoid this issue:
Go back to your app target (not the test target), set the Symbols Hidden by Default build setting to NO
Now there is no need to add any source files to the Compile Source for the test target as long as the original target is set as a dependency.
Upvotes: 6
Reputation: 543
You have to include the .m file for any of your classes that you reference from your test code in the list of compiled sources for your test target. From the error message you provided, that sounds like your problem. In XCode 4.2 you can add a compile source to a target by selecting your project in the project navigator, then selecting your test target, the Build Phases tab, and expanding the Compile Sources section. Click the "+" below the Compile Sources section and then select your class' .m file.
Upvotes: 0