适用于 iPhone 的 OCMock(iOS4、XCode 3.2.3)
我有最新版本的 OCMock (1.55) 和 XCode 3.2.3。
我在我的项目中创建了一个测试包目标。 在我的测试中使用 OCMock 的最佳方式是什么? 当我将 OCMock.framework 添加到测试包时,出现此构建错误:
"_OBJC_CLASS_$_OCMockObject", referenced from:
objc-class-ref-to-OCMockObject in NotificationTests.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I have the last version of OCMock (1.55) and XCode 3.2.3.
I have created a test bundle target in my project. What is the best way to use OCMock in my tests?
When I add OCMock.framework to the test bundle, this build error appears:
"_OBJC_CLASS_$_OCMockObject", referenced from:
objc-class-ref-to-OCMockObject in NotificationTests.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了同样的问题,这是我解决的方法:
删除ocmock.framework、复制文件阶段以及链接到ocmock标头的任何搜索路径。
从ocmock svn repo查看最新版本:http://svn.mulle-kybernetik .com/OCMock/trunk
构建 OCMockPhoneSim 目标
复制项目中的 libOCMock.a 和 Headers 文件夹文件夹
将 libOCMock.a 添加到您的框架中,并添加指向目标库搜索路径中的 headers 文件夹的链接。
然后就可以了!
希望这有帮助。
I had the same problem, here is how i solved it :
Delete ocmock.framework, the copy file phase, and any search path linking to ocmock header.
check out the latest version from ocmock svn repo : http://svn.mulle-kybernetik.com/OCMock/trunk
Build the OCMockPhoneSim target
Copy the libOCMock.a and Headers folder in your project folder
add the libOCMock.a to your framework and add a link to the headers folder in your target library search path.
Then it works !
Hope this helps.
请参阅 Colin Barrett 的“OCMock 和 iPhone”教程。
See Colin Barrett's "OCMock and the iPhone" tutorial.
user3135374 的回答主要帮助我完成这件事。
附加信息:
SDK 必须是 iPhone Simulator 4.0,因为 3.2 有一个错误,使其无法正确运行单元测试。很多人都在抱怨。我将其设置为我的单元测试目标的 BaseSDK。
您需要将其他链接器标志“-ObjC -force_load $(PROJECT_DIR)/path/to/libOCMock.a”添加到您的单元测试目标,否则您将收到大量运行时“无法识别的选择器发送到实例”错误
如果您想要一个具有单元测试的目标,您可以实际调试(设置断点),请按照本教程操作:
http://www.lostechies.com/blogs/scottdensmore/archive/2010/07/24/debugging-unit-tests-for-the-iphone-ipad.aspx
OCMock 论坛上的这个帖子有一个示例您可以使用的项目:
http ://www.mulle-kybernetik.com/forum/viewtopic.php?f=4&t=73&p=119#p119
user3135374's answer mostly helped me get this going.
Additional info:
The SDK must be iPhone Simulator 4.0 because 3.2 has a bug that makes it unable to properly run unit tests. Many people are complaining about it. I set this as the BaseSDK for my Unit Test target.
You need to add Other Linker Flags "-ObjC -force_load $(PROJECT_DIR)/path/to/libOCMock.a" to your Unit Test target or else you will get a lot of runtime "unrecognized selector sent to instance" errors
If you want a target that has unit tests you can actually debug (set breakpoints) follow this tutorial:
http://www.lostechies.com/blogs/scottdensmore/archive/2010/07/24/debugging-unit-tests-for-the-iphone-ipad.aspx
This thread on the OCMock forums has an example project you can use:
http://www.mulle-kybernetik.com/forum/viewtopic.php?f=4&t=73&p=119#p119