Search code examples
xcodestack-overflownsmanagedobjectocmock

Crash with Xcode 9 when mocking a NSManagedObject


Since downloading XCode 9, some of my unit tests have started to crash with a stack overflow (try searching for that these days!).

The problems seem to come from trying to create an OCMock of an NSManagedObject subclass, such as this line: OCMClassMock([User class]), where User is an NSManagedObject subclass.

There's a bug and discussion about this in the OCMock git repo.

The discussion mentions that OCMock supports mocking of NSManagedObject subclasses since version 3.4.

Any suggestions for fixing this or working around it? I guess it will probably need a fix to OCMock, but maybe there's an XCode setting that could be tweaked, or something?


Solution

  • I have just added a (preliminary) workaround to OCMock. Pease see the Github issue you linked to for details.