Linker errors during setup. Can't find up-to-date tutorials.

Discussion of the OCMock framework. If you have patches we would prefer you to send them to the mailing list, but attaching them to a topic is possible, too.

Linker errors during setup. Can't find up-to-date tutorials.

Postby Kelvin » 26 Apr 2011, 01:00


I have spent a couple of days trying to set up OCMock for an iPad project. I have created many bare-bones iPad dummy projects with very minimal lines of code, but I seem to confront the same issue over and over again.
It seems as if there is no actual up-to-date tutorial or guide I can reference.

My current issue is the following:
In my Xcode project (, I've simply added 1 logic unit test:
Code: Select all
#import "Test.h"
#import <OCMock/OCMock.h>

@implementation Test

-(void) testThis
   id mock = [OCMockObject mockForClass: [NSString class]];
   [mock stub];


Of course, this code is rather useless right now but it serves the purpose for verifying that everything else is in place.
By following this guide - , I got my things set up to reflect what was written.

According to the guide, I set up my project structure like so:

So given the unit-test code & project setup above, I get this output:

Here are my questions:
-- Why is it that if I placed a 'copy files' build phase between compile & link, I get an output where it compiles, links and then copies?
-- If I place it to copy before it compiles, the output correctly follows that order (copy, compile, link). Still it doesn't work. Should it work though?
-- I know I can either copy the source to the project or create a static library.
According to - , there no way to just use the framework anymore?
Here's the excerpt :
Before Xcode 3.2.3, you used to be able to simply add the OCMock.framework to the "Link Binary With Libraries" build phase of your unit tests. This appears to have stopped working, so you have two options: you can include the OCMock source Xcode project and declare a build dependency on its static library target, or you can build the static library once and put the following header files somewhere accessible to your Xcode build:

I didn't want to rebuild the library over and over so I built the static library once and put the libOCMock.a and OCMock.h files in a directory in my project and added that directory to the LIBRARY_SEARCH_PATHS in the unit-test target configuration 2.

I also noticed the similar info with - , so I guess the only way to get it working is by compiling source code or using the static library...? The framework route is no longer viable?

My references:
-- (June 28th, 2010)
-- (November 10th, 2008)
-- (October 26, 2009)

Any info on how to get this linking would be much appreciated.

Re: Linker errors during setup. Can't find up-to-date tutori

Postby Kelvin » 26 Apr 2011, 01:08

I can't find a way to edit the post, so I will add the extra bits of details here:

This is an iPad project using OCMock 1.77 with Xcode 3.2.5.
I assume that the most up-to-date reference available for my situation is -

Return to OCMock