Search code examples
testingiosstatic-librariesocunit

Is it possible to unit test a static library project using XCode's SenTestingKit?


I've created an iOS unit test target for doing logic tests following the steps provided in Apple's documentation.

However my build fails and i get the following error:

Undefined symbols:
"_OBJC_CLASS_$_MyClass", referenced from: objc-class-ref-to-MyClass in LogicTests.o ld: symbol(s) not found collect2: ld returned 1 exit status

Ordinarily, if I wanted to use my static library within an application I would include the library.a file, and the headers(including the MyClass.h file...). Is something additional required to run logic tests on a static library WITHIN that same project if my test cases are utilizing MyClass.h ?

Tjhanks


Solution

  • I actually just solved it. I had to copy all of the .m files in my project to the LogicTest target's 'Compile Sources'. As well as add the frameworks the sources reference to the 'Link Binary With Libraries' section of the target.

    I hope this helps others