Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Undefined symbols for architecture x86_64" when setting up a very basic Unit Testing for a console application

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:

enter image description here

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?

like image 264
ellmo Avatar asked Apr 21 '14 20:04

ellmo


People also ask

What is undefined symbols for architecture x86_64?

Why Is the Undefined Symbols for Architecture x86_64: Error Happening? This error is happening due to the lack of included values inside the declared statements in your code. The browser is going to render the information incorrectly and show this error, especially if you are working with Main and Similarity tools.

What is unit testing in embedded C?

Unit testing is a method of testing software where individual software components are isolated and tested for correctness. Ideally, these unit tests are able to cover most if not all of the code paths, argument bounds, and failure cases of the software under test.


1 Answers

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.

checking Target Membership for Fraction.m

like image 66
ellmo Avatar answered Oct 17 '22 07:10

ellmo