2

每当我运行单元测试应用程序以查找是否存在 appdelegate 时,都没有使用测试套件

-(void)testAppDelegate
{
id app_delegate=[[UIApplication sharedApplication]delegate];
STAssertNotNil(app_delegate,@"delegate not found");
}

我得到了这个错误。请帮忙。

“_OBJC_CLASS_$_UIApplication”,引用自:

  objc-class-ref-to-UIApplication in Tests.o

ld:未找到符号

collect2: ld 返回 1 个退出状态

4

1 回答 1

3

我相信这是一个链接器错误,而不是运行时错误。您需要将您在 iPhone 构建目标中使用的相同框架链接到您的单元测试目标。特别是此错误表明 UIKit 框架未链接到您的单元测试目标。(为了安全地将 UIKit、Foundation 和 CoreGraphics 链接到您的目标)。

您可以这样做,通过在 XCode 中展开 Targets 节点,获取有关单元测试目标的信息,然后在 General 选项卡下,在 Linked Libraries 中添加这 3 个框架;)

希望这会有所帮助,莫西

于 2011-01-05T08:52:30.923 回答