Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "An NSManagedObject of class 'ClassName' must have a valid NSEntityDescription" when using CoreData from a framework

Tags:

ios

core-data

I have separated my Data Access Layer (DAL) in a framework in order to be able to use it in both the app and its Today widgets. I set up everything and it compiled but at runtime when I tried to create a NSPersistentContainer the app crashed with the infamous An NSManagedObject of class 'ClassName' must have a valid NSEntityDescription.

What I tried:

  • checking if the name of the persistent container is the same as the data model
  • selecting Current Product Module for the model class module
like image 604
AXE Avatar asked Feb 14 '18 15:02

AXE


1 Answers

What helped:

  • checking all targets that will use CoreData for the xcdatamodeld file

To do this:

  1. Select the xcdatamodeld file in Project Navigator
  2. Open Utilities on the right side
  3. Open File Inspector
  4. Check all needed targets under Target Membership
like image 171
AXE Avatar answered Nov 01 '22 11:11

AXE