How do I reference the Model that I have created in my static library project?
This returns null and throws and error because the resources live in this static library:
//this code is in the static library
- (NSManagedObjectModel *)managedObjectModel
{
if (__managedObjectModel != nil) {
return __managedObjectModel;
}
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"eCommerceEngine" withExtension:@"mom"];
__managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return __managedObjectModel;
}
How do I change this to pull from this static library?
On the iPhone, static libraries have a .a extention and can only contain code. This means that any resources (xibs, images, etc…) must be packed either in a bundle or shipped separately than the library.
See iOS Library With Resources
If you want to use a preconfigured model from a library, I would suggest building the model programmatically, using the Entity API, and not use a model file at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With