I'm receiving an 'Cannot create an NSPersistentStoreCoordinator with a nil model' error after deleting my application from device. I'm testing an iPhone app in an iPad device. I've put this code to check if I have the file in AppDelegate.m:
- (NSManagedObjectModel *)managedObjectModel {
if (__managedObjectModel != nil) {
return __managedObjectModel;
}
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Name" withExtension:@"momd"];
if ([[NSFileManager defaultManager] fileExistsAtPath:[modelURL path]]) {
NSLog(@"%@", [modelURL path]); //This is printed because file exists
}
__managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return __managedObjectModel;
}
The problem is that [NSManagedObjectModel initWithContentsOfURL] is returning nil value.
I've done the following things, with no success:
- Change managedObjectModel instantiation with this
__managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil]; - Cleaned Build Folder and Cleaned project
- Restarted Xcode
- Restarted computer
- Changed "momd" to "mom"
.xcdatamodeldis in Copy Bundle Resources and Compile Sources- Renamed
.xcdatamodeldand cleaned and closed Xcode project several times - Turned off and on the device
- Deleted folders from:
$ cd /Users/john/Library/Developer/Xcode/DerivedData - Changed sqlite name for forcing database generation
- Deleted (again) application from devine
I've been searching the solution for hours, and I still cannot find it.