I am trying to create CoreDataKit using a static library.
It contains:
- xcdatamodel or model file
- NSManagedObject or Entity (
Since static library can have only objects files hence model file can't be part of static library.
To make it happen I created separate bundle having only model file and copied this bundle to my xcode project using this link ( core data in a static library for the iPhone)
Now, while loading Person entity
let personEntity = NSManagedObject(entity: entity, insertInto: context) as! Person
I got below error:
Unable to load class named 'MyStaticLibraryModels.Person' for entity 'Person'. Class not found, using default NSManagedObject instead.
and exception:
Could not cast value of type 'NSManagedObject_Person_' (0x600000243b40) to 'ONCoreDataKit.Person' (0x105d71a68).
The other approach could be to use framework which can contain model file and can be dynamically loaded.
Since loading dynamic framework can take some extra time I am interested in creating static library for faster access.