views:

69

answers:

3

I've been trying to determine the cause of this error for days now. Tried doing simple projects by I could not get the unit tests to work? Does anyone know how to solve this problem?


Building target “ChildTests” of project “Person” with configuration “Debug” — (2 errors) Linking /Users/me/Desktop/Person/build/Debug-iphonesimulator/ChildTests.octest/ChildTests(1 error) ".objc_class_name_Child", referenced from: literal-pointer@__OBJC@__cls_refs@Child in ChildTests.o symbol(s) not found collect2: ld returned 1 exit status

 ...


Pardon me, I am new to iphone development.

A: 

Linker errors normally mean you've neglected to add a framework or static library to your project and/or neglected to add the header import for the library in question.

What unit test library/framework are you using?

If you're new to the platform, you may be causing yourself unnecessary confusion by trying to start out with unit tests. Unit testing can be very beneficial to delivering a stable final product, however, it doesn't seem to me to be a good place to start out. I would suggest you get your app working first and then add unit tests later once you're sure you're going to develop it to completion.

Matt Long
+2  A: 

The missing symbol is .objc_class_name_Child. I'm guessing you have a class called Child but its implementation file is not being built as part of your test target.

To fix the problem find the file (probably called Child.m) and make sure your test target is checked in the Targets tab of the file's File->Info.

Will Harris
A: 

Thanks Matt and Will! I did Matt's suggestion. I let go of unit testing since most of my classes were too interdependent and it gave me more confusion than good especially for a newbie like me. But special thanks to Will, I now know how to add a class into the test target. Before I would have to remove the implementation from the original target and add it again with both targets checked. I am new to xcode, so please pardon my ignorance.

clyde