For the first time I'm trying to use CocoaPods and ObjectiveRecord. ObjectiveRecord's github page
When I try to save my object, I get the following error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot create an NSPersistentStoreCoordinator with a nil model'
*** First throw call stack:
(
0 CoreFoundation 0x01aae5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x018318b6 objc_exception_throw + 44
2 CoreData 0x00023b0e -[NSPersistentStoreCoordinator initWithManagedObjectModel:] + 398
3 ObjectiveRecordTest 0x00003691 -[CoreDataManager persistentStoreCoordinatorWithStoreType:storeURL:] + 193
4 ObjectiveRecordTest 0x000030f9 -[CoreDataManager persistentStoreCoordinator] + 169
5 ObjectiveRecordTest 0x00002dba -[CoreDataManager managedObjectContext] + 106
6 ObjectiveRecordTest 0x00003f26 +[NSManagedObjectContext(ActiveRecord) defaultContext] + 86
7 ObjectiveRecordTest 0x0000477a +[NSManagedObject(ActiveRecord) create] + 58
8 ObjectiveRecordTest 0x00002112 -[ViewController savePressed:] + 82
9 libobjc.A.dylib 0x01843874 -[NSObject performSelector:withObject:withObject:] + 77
10 UIKit 0x005a10c2 -[UIApplication sendAction:to:from:forEvent:] + 108
11 UIKit 0x005a104e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
12 UIKit 0x006990c1 -[UIControl sendAction:to:forEvent:] + 66
13 UIKit 0x00699484 -[UIControl _sendActionsForEvents:withEvent:] + 577
14 UIKit 0x00698733 -[UIControl touchesEnded:withEvent:] + 641
15 UIKit 0x005de51d -[UIWindow _sendTouchesForEvent:] + 852
16 UIKit 0x005df184 -[UIWindow sendEvent:] + 1232
17 UIKit 0x005b2e86 -[UIApplication sendEvent:] + 242
18 UIKit 0x0059d18f _UIApplicationHandleEventQueue + 11421
19 CoreFoundation 0x01a3783f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
20 CoreFoundation 0x01a371cb __CFRunLoopDoSources0 + 235
21 CoreFoundation 0x01a5429e __CFRunLoopRun + 910
22 CoreFoundation 0x01a53ac3 CFRunLoopRunSpecific + 467
23 CoreFoundation 0x01a538db CFRunLoopRunInMode + 123
24 GraphicsServices 0x02e9e9e2 GSEventRunModal + 192
25 GraphicsServices 0x02e9e809 GSEventRun + 104
26 UIKit 0x0059fd3b UIApplicationMain + 1225
27 ObjectiveRecordTest 0x000028ad main + 141
28 libdyld.dylib 0x02b4070d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
This is what my Podfile looks like:
platform :ios
pod 'ObjectiveRecord'
I'm using the new xcworkspace file instead of the old xcode project file and I've imported the following two in the .pch file:
#import "ObjectiveRecord.h"
#import <CoreData/CoreData.h>
I've added Core Data in the project's settings page. Now when I'm using the provided code from the example of the github page:
Person *john = [Person create];
john.name = @"John";
[john save];
I get the error above. Have I forgotten something? I've been searching for some time now but I can't figure it out.
I'm using Xcode 5.0.2 and iOS 7.
Update: It turns out that, in the general project settings, in the frameworks and libraries section, there is a red "libPods.a" entry. That means that it's missing, right? Could this be the issue?
From the doc:
Custom CoreData model or .sqlite database
If you've added the Core Data manually, you can change the custom model and database name on CoreDataManager
[CoreDataManager sharedManager].modelName = @"MyModelName";
[CoreDataManager sharedManager].databaseName = @"custom_database_name";
https://github.com/mneorr/ObjectiveRecord/blob/master/README.md Reading docs will always help.
Ok, I fixed the error by renaming my Model.xcdatamodeld into appname.xcdatamodeld. I'm not sure why it fixed it but, I always named my models "Model" before, without any problems, but now it works. I hope this helps other people having this problem. I as well found out that the red colored "libPods.a" entry doesn't mean that it's missing. So even if it's red, everything is fine.
User contributions licensed under CC BY-SA 3.0