OCUnit链接问题问题

发布于 2024-10-22 00:55:05 字数 350 浏览 2 评论 0原文

我想为我的课程编写单元测试,但我无法解决链接问题。 在测试标头中,我做了#import“myclass.h”,但是当我在测试实现文件中分配myclass对象时,它找不到符号。我已经添加了依赖项。

"OBJC_CLASS_$_PhotoArrayControl", referenced from:
 objc-class-ref-to-PhotoArrayControl in PhotoArrayControlUnitTest.o
 (maybe you meant: _OBJC_CLASS_$_PhotoArrayControlUnitTest)
 ld: symbol(s) not found

有什么想法吗?

I want to write unit test for my classes but I cannot solve linking problem.
in test header, i did #import "myclass.h" but then when i allocate myclass object in test implementation file, it couldn't find symbol. I already added dependency tho.

"OBJC_CLASS_$_PhotoArrayControl", referenced from:
 objc-class-ref-to-PhotoArrayControl in PhotoArrayControlUnitTest.o
 (maybe you meant: _OBJC_CLASS_$_PhotoArrayControlUnitTest)
 ld: symbol(s) not found

any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谜兔 2024-10-29 00:55:05

这种错误很难诊断,所以可能性不大,但链接错误意味着,虽然编译器在解析阶段被告知特定符号,但在最后一步,它注意到它不知道它在哪里。这可能意味着您的 .m 文件未与其余测试代码一起编译,这可能是因为您的 .m 文件不是测试目标的成员。

在 Xcode 4 中,选择 .m 文件并打开右侧面板(通过单击工具栏“查看”类别中最右侧的图标)。应该有一个名为“目标会员”的部分;确保您的测试包已被选中。在 Xcode 3 中,将测试包设为活动目标,并确保选中项目资源管理器最右列中的复选框。

This kind of error is hard to diagnose so it's a long shot, but link errors mean that while your compiler was told about a specific symbol during the parsing stage, in the final step, it noticed that it doesn't know where it is. This likely means your .m file didn't get compiled with the rest of your test code, which is probably because your .m file isn't a member of your test target.

In Xcode 4, select you .m file and bring up the right panel (by clicking the rightmost icon in the "View" category of the toolbar). There should be a section called "Target Membership"; make sure your test bundle is checked. In Xcode 3, make your test bundle your active target and make sure the checkbox in the rightmost column of the project explorer is checked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文