xcodecocoa-touchocmocksentestingkitxctest

OCMock test not getting compiled with XCTest


Has anyone tried using OCMock test framework with XCTest framework? We were using OCMock test framework with SenTest framework and ever since we migrate from SenTest to XCTest, OCMock tests stops compiling. I know, XCTest does not have in-built support for OCMock test framework and below are the steps I have tried with by far:

  1. Go to Edit --> Refactor --> Convert to XCTest.
  2. Add XCTest framework to the test target.
  3. Go to Editor --> Add Build Phase --> Add Copy Files Build Phase
  4. Add the OCMock framework to the Copy Files build phase.
  5. Set the copy destination to the Products Directory.

After doing all this XCode is not able to locate the OCMock test framework and is complaining the same while compilation.

Any suggestions.


Solution

  • I just noticed this which could be the potential reason for this issue:

    After reading through some documentation I get to know that OCMock versions 2.2 and later work with XCTest. I am using using 2.1 version which could be a reason for compilation errors.

    Reference: XCode with XCTest and OCMock Versions