Sorry if this is the wrong forum, but I am using the book and got distracted with an interesting function and topic…
Although XCTest is not included in this book (although I am only at Chapter 20), I noticed discussions and examples on forums about XCTest for unit testing. The Cocoa examples and testing tutorials worked fine. So I thought I would try adding a testing target to the command line tools project for the BNRPerson class in the chapter challenges. However its not proving easy to do, so I decided to create a new test project Chapter20 just in case I messed up something.
I added BNRPerson class files to the new test project and got that running fine from main.m. I then added a test target called Chapter20Testing, and proved I could perform the test against the test example added by default, all fine. However, if I import BNRPerson.h and write a small test function I get the following error when I perform the test:
Undefined symbols for architecture x86_64:
“OBJC_CLASS$_BNRPerson”, referenced from:
objc-class-ref in Chapter20Test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Clearly there is some missing setting somewhere to pull in the BNRPerson in to the linker for the product test, but I haven’t got a clue where to look. I was wondering if command line tools aren’t capable of using XCTest, but some google searches say otherwise.
Help please if you can…