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

Hi,

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 (http://www.sendspace.com/file/l676b6), 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];
}

@end


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 - http://iamthewalr.us/blog/2008/11/ocmock-and-the-iphone/ , I got my things set up to reflect what was written.

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

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

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 - http://alexvollmer.com/posts/2010/06/28/making-fun-of-things-with-ocmock/ , 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:

NSNotificationCenter+OCMAdditions.h
OCMArg.h
OCMConstraint.h
OCMock.h
OCMockObject.h
OCMockRecorder.h
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 - http://www.mulle-kybernetik.com/forum/viewtopic.php?f=4&t=73#p108 , 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:
-- http://alexvollmer.com/posts/2010/06/28/making-fun-of-things-with-ocmock/ (June 28th, 2010)
-- http://iamthewalr.us/blog/2008/11/ocmock-and-the-iphone/ (November 10th, 2008)
-- http://everburning.com/news/poking-objective-c-with-a-testing-stick/ (October 26, 2009)

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

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 - http://alexvollmer.com/posts/2010/06/28/making-fun-of-things-with-ocmock/
Kelvin
 


Return to OCMock



cron