XCode - iOS - <OCMock/OCMock.h> file not found
Asked Answered
I

2

8

I Have an iOS application that I am trying to add OCMock to in order to better unit test it. I've followed the instruction on ocmock.org as well as instructions I've found in other places but still I cannot get my test code to compile.

Here's what I've done

Added the source code to my project directory enter image description here

Create the groups in my project to mimic my file system enter image description here

I selected the option to add to my test targets so the framework was added appropriately as well as the Library Search Path enter image description here enter image description here

Then I manually added the headers to the Header Search Path enter image description here

And added the -ObjC linker flag enter image description here

Then when I go to import the header file, I get the file not found error enter image description here

Any ideas what I am missing here???

Indestructible answered 8/9, 2014 at 2:10 Comment(0)
I
18

You have the search path test/libraries/OCMock. Then you have #import <OCMock/OCMock.h>.

This fails because there is no file test/libraries/OCMock/OCMock/OCMock.h.

You use the search path test/libraries, or you can create a prefix directory to hold OCMock and have the search path point at that.

I generally have a directory with the library name and version number before the actually directory.

The directory test/libraries/OCMock-X.X.X could contain the OCMock directory. That way the search path still be more specific: test/libraries/OCMock-X.X.X and you still use OCMock/OCMock.h as the include.

Immunogenic answered 8/9, 2014 at 2:21 Comment(2)
Thank you so much! That was it! I wasted so much time on this today. As for the directory with the version number, do you usually but the lib in there too?Indestructible
I try to keep the original packaging of the library. So yes, I think it would be test/libraries/OCMock-X.X.X/libOCMock.aImmunogenic
W
0

One more thing to check, for anyone else having this problem - I copied OCMock from one project to another and everything looked right, but it wasn't finding the include file. It turned out that even though I had the right groups in Xcode, the files had all been dumped into one directory. I needed to create folders on disk and associate them with the groups in Xcode. The accepted answer here clued me in to what was wrong (though as is often the case, in hindsight it should have been obvious).

Wiring answered 31/1, 2015 at 1:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.