OCMock is distributed as a basis, and the iPhone does not allow you to create your own custom frameworks (there are good reasons to do this on a device with 128 MB of RAM and without sharing).
The solution that I see in many places on the Internet is to put OCMock.framework in / Library / Framework or elsewhere in the standard wireframe search paths. This is not a good solution: your build system now depends on the state of your particular machine. Not good.
Another option is to add the source for OCMock to your unit test target object. This will work, but is not necessary, since your tests will never run on the iPhone 2, so why bother them for ARM? The executables created for the iPhone simulator, which are binary files in Mac OS X, can work well with dynamic libraries. We can use this to our advantage.
The following is what I consider the best way to get OCMock working with iPhone projects:
First add OCMock.framework to your project. Make sure to add it to the Unit Tests target program, not your application.
Then add the “Copy Files” phase to the “Test Units” target. Set it up like this:
Destination: Absolute Path Full Path: $ (BUILT_PRODUCTS_DIR)
Now drag OCMock.framework onto the new Copy Files phase to add it to the list of files you want to copy.
Finally, drag the “Copy Files” phase, which I renamed to “Copy OCMock,” between the “Compile Sources” and “Linking Binary Files to Libraries” steps.
Here it is! Run (and run, I mean build) your tests, and everything should work correctly.
Arunjack
source share