问题
I'm trying to use MagicalRecord with a data model in a static library. When I just call
[MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:@"db.sqlite"];
in the library, it doesn't seem to load the data model. A call to
[TheObject MR_createEntity];
will throw an exception:
could not locate an entity named 'TheObject' in this model.'
How do I load the model I want to use? An overview of the project layout:

I figure MR tries to load the model from the main bundle by default?
[MagicalRecord setDefaultModelNamed:@"TheModel.xcdatamodeld"];
will also not find it. And if I try to copy the library's model resource file into the main project, Xcode complains by crashing.
回答1:
building the static library produced a compiled .mom file for the data model. (open the lib's Products group, right click the compiled lib, show in Finder) this file can be added to the main project's resources, making it available in the main bundle.
来源:https://stackoverflow.com/questions/13181662/magicalrecord-in-a-static-library-how-do-i-load-the-data-model