'An NSManagedObject of class 'className' must have a valid NSEntityDescription.' error

The issue was that I did not checked Class Module: current product module for CDWorkout Entity.


In my case the same problem was in @objc modifier in auto-generated header of data-class

@objc(CachedMovie)
public class CachedMovie: NSManagedObject {

I just removed @objc(CachedMovie) and it began to work


I had a silly minor issue that resulted in the same error. I was initializing NSPersistentContainer with the incorrect name.

It should have the same name as the source file with the extension .xcdatamodeld. e.g. modelFileName.xcdatamodelId

let persistentContainer = NSPersistentContainer(name: "modelFileName")