1

I'm running Xcode 6.1.1. I setup a new test target using: File > New > Target

Running the test with the empty template works fine. I import a single header, ServerController, and tried to make an instance:

#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "ServerController.h"

@interface Tixie_Tests : XCTestCase

@end

@implementation Tixie_Tests

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
    ServerController * s = [[ServerController alloc] init];
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testExample {
    // This is an example of a functional test case.
    XCTAssert(YES, @"Pass");
}

- (void)testPerformanceExample {
    // This is an example of a performance test case.
    [self measureBlock:^{
        // Put the code you want to measure the time of here.
    }];
}

@end

Now running the tests gives me this:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_ServerController", referenced from:
      objc-class-ref in <omitted>.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
raphael
  • 447
  • 4
  • 17
  • Did you add the ServerController.m file to the new target by checking the target checkbox in the attribute inspector panel? – Lolloz89 Jan 13 '15 at 18:38
  • No, I know that works but I've read that it causes other problems and shouldn't it work anyway because it's set to build my primary target? – raphael Jan 13 '15 at 20:09

1 Answers1

0

For linker errors looking for a class in your app... set the “Symbols Hidden by Default” build setting to “NO” in your app target. This makes all your app classes available to your test target automatically... So, that means:

Project Navigator > Select your project

Targets > Select your App (not Tests)

Build Settings > Search for "Symbols Hidden By Default"

"Symbols Hidden By Default" > Change it from "YES" to "NO"

check the origin:answer

Community
  • 1
  • 1
user1413910
  • 1
  • 1
  • 2