架构i386 / armv7 / armv7s的OCMVerify和Undefined符号

时间:2014-08-29 18:17:04

标签: ios ocmock

我在我的项目中使用OCMock(版本3.1.1),我正在尝试使用OCMVerify宏来检查是否在我的对象中调用了某个方法。

问题在于我把这行:

OCMVerify([mockEngine notify]);

XCode向我显示以下链接错误(我已尝试过所有平台):

Undefined symbols for architecture i386:
  "OCMMakeLocation(objc_object*, char const*, int)", referenced from:
      -[T009_EngineTest testPostEvent] in T009_EngineTest.o
ld: symbol(s) not found for architecture i386

我从网站上获取了该库的最新版本,并且我也试图自己编译它。

这是单元测试代码:

Engine *mockEngine = OCMClassMock([Engine class]);
Object *obj = [[Object alloc] init];

[mockEngine startUp];
[mockEngine run];
[mockEngine postEvent:obj];

[NSThread sleepForTimeInterval:0.5];

OCMVerify([mockEngine notify]);   // << THIS LINE CREATES THE LINK PROBLEM..

[mockEngine shutDown];

如果我评论该行,编译器链接成功.. 似乎该符号不在库二进制文件中,但我检查它是在Xcode编译源列表中。 然后我做了一个解决方法...我将这行(OCMock的原始代码)硬编码到我的单元测试文件中:

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

它有效! 现在我想知道OCMock中是否有一些错误,或者我做错了什么!

这是声明外部OCMakeLocation函数的原始头文件: https://github.com/erikdoe/ocmock/blob/master/Source/OCMock/OCMLocation.h 在这里它的实现: https://github.com/erikdoe/ocmock/blob/master/Source/OCMock/OCMLocation.m

感谢。

0 个答案:

没有答案