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: