Reputation: 3693
Our live app in Appstore crashes with the following reason
Fatal Exception: NSInvalidArgumentException
CoreData: Cannot load NSManagedObjectModel. nil is an illegal URL parameter
Here is the corresponding code to that.
- (NSManagedObjectModel *)managedObjectModel {
if (_managedObjectModel != nil) {
return _managedObjectModel;
}
NSString *bundlePath = [[NSBundle mainBundle]pathForResource:@"DBResources" ofType:@"bundle"];
NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
NSURL *modelURL = [bundle URLForResource:@"Profile" withExtension:@"momd"];
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return _managedObjectModel;
}
I did the basic check ups like making sure our momd file has the same name and its part of the resources.
Any reasons why it would crash from Appstore only? Any reasons why it would crash on those devices and not iphone 5s and above?
Any help would be appreciated
Upvotes: 0
Views: 1579
Reputation: 71
It turns out that the cause of this is "app thinning".
We just ran into a case where the presence of an 'arm64' entry in our framework's resource .bundle info.plist (as the architecture) caused ONLY armv7s devices to have the bundle stripped in the final, installed IPA.
As the architecture is not needed for the resources (and specifically here the mom/momd file), removing that architecture entry from the .bundle info.plist solves the problem.
It turns up in app store releases because of the thinning done behind the scenes, and will not generally occur when deploying via Hockey/Fabric.
Hope this helps - @neelesh I know your question was ages ago.
Upvotes: 3