OCMock for iPhone (iOS4, Xcode 3.2.3)

I have the latest version of OCMock (1.55) and Xcode 3.2.3.

My project created the goal of a test suite. What is the best way to use OCMock in my tests? When I add OCMock.framework to the test package, 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 
+3
source share
3 answers

I had the same problem, here is how I solved it:

  • Delete ocmock.framework, the phase of the copy file, and any search path associated with the ocmock header.

  • check out the latest version from ocmock svn repo: http://svn.mulle-kybernetik.com/OCMock/trunk

  • Create an OCMockPhoneSim Target

  • Copy the libOCMock.a folder and the headers to the project folder

  • add libOCMock.a to your infrastructure and add the link to the headers folder in the search path of the target library.

Then it works!

Hope this helps.

+4
source

user3135374's answer basically helped me achieve this.

Additional Information:

  • The SDK should be iPhone Simulator 4.0, because 3.2 has an error due to which it cannot correctly perform unit tests. Many complain about it. I installed this as BaseSDK for my Unit Test goal.

  • You need to add other linker flags "-ObjC -force_load $ (PROJECT_DIR) /path/to/libOCMock.a" to your Unit Test target, otherwise 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 guide: 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 that you can use:

http://www.mulle-kybernetik.com/forum/viewtopic.php?f=4&t=73&p=119#p119

0
source

Source: https://habr.com/ru/post/1314904/


All Articles