How to fix Core Data error: "Receiver type xxx for instance message is a forward declaration"

Receiver 'UIImage' for class message is a forward declaration

http://stackoverflow.com/questions/8815200/receiver-type-for-instance-message-is-a-forward-declaration

How to fix Core Data error: "Receiver type xxx for instance message is a forward declaration"

Core Data is great. But when you add it to an existing project Xcode throws some random error messages at you that make you doubt your sanity. Again.

Legitimately copied and pasted code from Apple’s own templates generates totally useless errors such as Receiver type ‘NSManagedObjectContext’ for instance message is a forward declaration. This isn’t a problem for Xcode when creating a new project that uses Core Data, with the very same code.

Thanks to this pre-processor macro all those error messages disappear as if by magic, and the project builds fine – just as it should. Add it to the complaining class somewhere near the top:

Note that you also need to add the Core Data Framework to your project for Core Data to work. It seems obvious, but it’s easily forgotten.