"Undefined symbols for architecture x86_64" when setting up a very basic Unit Testing for a console application
console-application, linker, objective-c, unit-testing, xcode5
Solution
Murphy's Law, of course I found the answer 3 minutes after posting a question that bugged me for hours:
The class I want to test needs to be a member of the test target. After checking the appropriate "Target Membership" for the Fraction class file the errors disappeared.
Problem
I'm new to Objective-C and XCode and consider me mentally challenged when discussing compiled languages in general. I have no idea how linkers work and the amount of build settings in every IDE I've had the discomfort of working with simply scares me. I've started learning ObjC a few days ago and of course I started with a Console Application project. Everything is fine so far, but I have a Ruby / Rails background which made me want to immediately understand how to set up even the most basic TDD environment in XCode5. I used this official dev doc but it's less than thorough. Taking the trial and error path I simply added a XCTest target to the Project and then added a Test Case Class, testing my `Fraction` class: ``` #import <XCTest/XCTest.h> #import "Fraction.h" @interface FractionTest : XCTestCase @end @implementation FractionTest - (void)setUp { [super setUp]; } - (void)tearDown { [super tearDown]; } - (void)testExample { Fraction *fraction = [Fraction new]; } @end ``` When running tests the linker can't find referenced symbols: I've read about setting up Bundle Loaders and Test Host, but nobody truly explains which target they should be set on. They don't work for me and I'm wondering if such a simple, 3-file large "project" even needs tweaking around the Build Settings. How can I simply add a Test Class that will test another class with simple assertions?