在 iPhone 中进行单元测试时出现以下错误
每当我运行单元测试应用程序来查找 appdelegate 是否存在时,
-(void)testAppDelegate
{
id app_delegate=[[UIApplication sharedApplication]delegate];
STAssertNotNil(app_delegate,@"delegate not found");
}
我都会收到此错误。请帮忙。
“_OBJC_CLASS_$_UIApplication”,引用自:
Tests.o 中的objc-class-ref-to-UIApplication
ld:未找到符号
collect2: ld 返回 1 退出状态
whenever i run the unit testing application to find whether appdelegate is there r not using the test suit
-(void)testAppDelegate
{
id app_delegate=[[UIApplication sharedApplication]delegate];
STAssertNotNil(app_delegate,@"delegate not found");
}
i got this error. Please help.
"_OBJC_CLASS_$_UIApplication", referenced from:
objc-class-ref-to-UIApplication in Tests.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这是链接器错误而不是运行时错误。
您需要将 iPhone 构建目标中使用的相同框架链接到单元测试目标。特别是此错误表明 UIKit 框架未链接到您的单元测试目标。
(为了安全起见,请将 UIKit、Foundation 和 CoreGraphics 链接到您的目标)。
您可以通过展开 XCode 中的“目标”节点来执行此操作,获取有关单元测试目标的信息,然后在“常规”选项卡下的“链接库”中,您需要添加这 3 个框架;)
希望这会有所帮助,
莫西
I believe this is a linker error and not a runtime error.
You need to link the same frameworks that you use in your iPhone build target to your unit test target. Particularly this error indicates that the UIKit framework is not linked to your unit test target.
(To be safe link UIKit, Foundation and CoreGraphics as well to your target).
You can do this, by expanding the Targets node in XCode, get info on your unit test target, and under the General tab, in the Linked Libraries you need to add these 3 frameworks ;)
Hope this helps,
Moszi