gonzalezreal / Groot

From JSON to Core Data and back.
Other
534 stars 61 forks source link

Could not locate the entity for \(className) even though it exists #90

Open mariusschoenefeld opened 6 years ago

mariusschoenefeld commented 6 years ago

I installed Groot via cocoapods and using xcode 9.3, swift 4.

When I Call:

let context = NSManagedObjectContext.mr_default()
let _: [MObject] = try objects(fromJSONArray: correctedJSON, inContext: context)

It throws the fatalError I can't explain to my self why. this object exists. Any ideas?

gonzalezreal commented 6 years ago

Hi @mariusschoenefeld. Is there any message with the fatalError? Without more context, I can only guess that MObject does not have a corresponding entity in the Core Data model.

pablogeek commented 6 years ago

it is happening the same to me. When we get thelet className = String(reflecting: self) the class name has Module.Entity and the entities only shows Entity

billsea commented 6 years ago

Yes, I'm experiencing the same issue at: let className = String(reflecting: self)

vincilbishop commented 5 years ago

Yeah, it's a real issue...see this PR: https://github.com/gonzalezreal/Groot/pull/94

gonzalezreal commented 5 years ago

Hi all,

Please make sure that the module of the class is properly identified in the model:

screenshot 2018-12-12 at 09 23 27

In this example, taken from Groot unit tests, the model and the class are in the same module. If your case is different, you will need to be explicit about the module in which the class is implemented.

In case you don't control the model (ie. it is in a Cocoapod like specified in #94) you will need to discuss it with the author of that model.