Reputation: 9144
I am trying to embed a core data model into a static library or a framework. I have stumbled upon a few tutorials and SO questions like this one. The process is to create a bundle target where you can embed the core data model file.
This is working fine, but it doesn't seem good enough for me. I have noticed that Google Analytics have implemented a static library that uses core data and all you have to add is headers and the .a file.
So my question is, how can we embed core data in a static library without having a bundle, just like Google Analytics?
Upvotes: 1
Views: 418
Reputation: 11920
You can create the model in code by instantiating instances of NSEntityDescription
, NSPropertyDescription
etc. This involves a lot of boiler plate code but it is relatively straight forward.
An alternative, which I can't recommend but will mention, is to include the ManageObjectModel in the binary in some form. It can then be extract to a temporary folder and read as per normal. (Embedding Resource Files in a Cocoa Foundation Command Line Tool)
Upvotes: 1