OCMock Linker Error 3.0.2 with Test File .mm

I am using OCMock 3.0.2, which I installed via cocoapods for my test purpose:

platform :ios, '7.0'
xcodeproj 'myProject.xcodeproj'

target :myTestTarget do
  pod 'OCMock', '~> 3.0.2'
end

link_with "myTestTarget"

In my test file (myTest.mm), I enabled OCMock and want to try a new in-place validation strategy, for example:

- (void) test_myTest
{
    MyObject *obj = [MyObject new];
    id robotMock = OCMPartialMock(obj);

    [obj testMethod];

    // some asserts
    OCMVerify([obj _internalMethodToBeCalled]);
}

It still seems normal. However, when I tried to run this specific test case, I get a linker error:

Undefined symbols for architecture i386:
  "OCMMakeLocation(objc_object*, char const*, int)", referenced from:
      -[MyTests test_myTest] in MyTests.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I checked that OCMock was retracted correctly, and links to OCMLocation.h / m are also listed. I see that OCMMakeLocation is apparently an extern function, but the .m file is present as a dependent project in my pods build target, but for some reason this is not related. I have to do my test as .mm, since I am including some C ++ files. Why would this be a problem for OCMock?

+4
2

OCMMakeLocation

OCMLocation.h:

extern OCMLocation *OCMMakeLocation(id testCase, const char *file, int line);

OCMLocation.m:

OCMLocation *OCMMakeLocation(id testCase, const char *fileCString, int line)
{
    return [OCMLocation locationWithTestCase:testCase file:[NSString stringWithUTF8String:fileCString] line:line];
}

C, Objective-C. , (, - ), , , , : Objective-C ++, ++-, mangling (. ). OCMLocation Objective-C, C-, ++, . ++, OCMock.h ++, , , .

, , , , , OCMock.h C :

#ifdef __cplusplus
extern "C" {
#endif
#import <OCMock/OCMock.h>
#ifdef __cplusplus
}
#endif
+7

, OCMock , x86_64 ( 64-), , i386 (32-). , , , , i386 x86_64.

, Cocoapods Debug, " ", true. Cocoapods, , Release, .

0

All Articles