Search code examples
xcodeunit-testingochamcrest

Adding OCHamcrest to an IOS Project


The documentation for the project says just add the framework and the linker flags and you are good to go. Hours and hours of wasted time later, I have figured out that that's not true. If you do that, the project does not see the header files. You have to put the framework somewhere were the compiler will find the headers. In my case, that worked when I dropped the framework into /Developer/Library/Frameworks and then told it to recurse in searching that framework directory (do not fiddle around with the headers search directories).

Then the problem I get is that the link fails with the message:

ld: framework not found OCHamcrestIOS

I noticed that the documentation for the project says that it was updated for Xcode 4. I pulled down the binary of the framework after checking out the code and wasting a ton of time unable to build the IOS version of the framework.

The documentation is here.

I also noticed in that documentation that the cocoa instructions tell you to put a copy files phase into the build. I tried that. Didn't change the outcome.

The last time I fell into a sink hole it was because the library was C++ code. Maybe that's still the problem.

Barring a rapid solution here, I am going to go back to using STAsserts, as sickening as that prospect is, this is far, far worse.


Update: reinstalled Xcode. Still doesn't work. There are cheap ways to make this work, like add the header files to the project. Did a blog post about this that brought out a person with the same experience.


Solution

  • So the solution I adopted for now, after much thrashing around, was to include the framework in the project.

    1. Create a group inside the Xcode project called Third Party.
    2. Link it to a folder called thirdparty.
    3. Go to the Add Files in Xcode and pick the framework.
    4. Drag it over to the dependencies.
    5. Run the tests, they pass!

    This is maybe preferable anyway because referencing it in /System/Library/Frameworks would present some versioning issues, and this can be setup very quickly. Furthermore, we have a continuous integration server, and having to get in there and sync versions whenever something changes is not so great.

    Thanks for checking it out, Derek.