【问题标题】:Xcode 6 test target: Unidentified Symbols for ArchitectureXcode 6 测试目标:Unidentified Symbols for Architecture
【发布时间】:2015-01-13 17:58:16
【问题描述】:

我正在运行 Xcode 6.1.1。 我使用以下方法设置了一个新的测试目标:File > New > Target

使用空模板运行测试可以正常工作。我导入了一个标头ServerController,并尝试创建一个实例:

#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

现在运行测试给了我这个:

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)

【问题讨论】:

  • 您是否通过选中属性检查器面板中的目标复选框将 ServerController.m 文件添加到新目标?
  • 不,我知道这行得通,但我读到它会导致其他问题,并且它不应该因为它被设置为构建我的主要目标而无论如何都行得通吗?

标签: ios xcode testing


【解决方案1】:

对于在您的应用程序中寻找类的链接器错误...在您的应用程序目标中将“默认隐藏的符号”构建设置设置为“否”。这使您的所有应用程序类自动可用于您的测试目标...... 所以,这意味着:

Project Navigator > 选择您的项目

Targets > 选择你的应用(不是测试)

构建设置 > 搜索“默认隐藏的符号”

“默认隐藏的符号”> 将其从“YES”更改为“NO”

查看来源:answer

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-01
    • 2018-05-11
    • 1970-01-01
    • 1970-01-01
    • 2021-09-16
    • 1970-01-01
    • 2014-12-15
    • 2014-10-13
    相关资源
    最近更新 更多