iPhone app crashes with coreData error

0

The first version of our app is in app store. In order to internationalize the app, one minor change has been to the core data model used by the app, the change being - a new attribute added to one of the entities.

I made the change by adding a new versioning model to the core data and by setting the current Core DataModel to this new version created.

In order to do a lightweight migration, I have added the required options as well like so:

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
    [NSNumber numberWithBool:YES],    NSMigratePersistentStoresAutomaticallyOption,
    [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
NSError *error = nil;
__persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc]  initWithManagedObjectModel:[self managedObjectModel]];
[__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error];

All this works fine when testing in the simulator and testing on the device ( when connected to MAC ). Once I made a ipa file and installed it on the device, the app crashes right when I start it. The default.png file shows up and then no other view is loaded.

The app crash log shows some issue with CoreData, but I am not able to put a finger and say this is what caused the problem. The crash log looks as below:

Last Exception Backtrace:
0   CoreFoundation                  0x374f388f __exceptionPreprocess + 163
1   libobjc.A.dylib                 0x31568259 objc_exception_throw + 33
2   CoreData                        0x324ee491 -[NSManagedObjectModel(_NSInternalMethods) _setIsEditable:] + 1
3   Company                         0x000dfe7f 0xde000 + 7807
4   Company                         0x000dfc91 0xde000 + 7313
5   Company                         0x000ecb5b 0xde000 + 60251
6   Company                         0x000ec8a3 0xde000 + 59555
7   Company                         0x000ec82b 0xde000 + 59435
8   Company                         0x000eb61d 0xde000 + 54813
9   UIKit                           0x3080cd59 -[UIViewController awakeFromNib] + 113
10  UIKit                           0x3089f207 -[UINib instantiateWithOwner:options:] +     1243
11  UIKit                           0x308a0861 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 137
12  UIKit                           0x307d6385 -[UIApplication _loadMainNibFileNamed:bundle:] + 37
13  UIKit                           0x3065f6eb -[UIApplication _loadMainInterfaceFile] + 223
14  UIKit                           0x3065972f -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 235
15  UIKit                           0x30627ac3 -[UIApplication handleEvent:withNewEvent:] + 1011
16  UIKit                           0x30627567 -[UIApplication sendEvent:] + 55
17  UIKit                           0x30626f3b _UIApplicationHandleEvent + 5827
18  GraphicsServices                0x3764322b PurpleEventCallback + 883
19  CoreFoundation                  0x374c7523 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 39
20  CoreFoundation                  0x374c74c5 __CFRunLoopDoSource1 + 141
21  CoreFoundation                  0x374c6313 __CFRunLoopRun + 1371
22  CoreFoundation                  0x374494a5 CFRunLoopRunSpecific + 301
23  CoreFoundation                  0x3744936d CFRunLoopRunInMode + 105
24  UIKit                           0x3065886b -[UIApplication _run] + 551
25  UIKit                           0x30655cd5 UIApplicationMain + 1081
26  Company                         0x000df5df 0xde000 + 5599
27  Company                         0x000df598 0xde000 + 5528


Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x3289832c __pthread_kill + 8
1   libsystem_c.dylib               0x34c0d208 pthread_kill + 48
2   libsystem_c.dylib               0x34c06298 abort + 88
3   libc++abi.dylib                 0x3221bf64 abort_message + 40
4   libc++abi.dylib                 0x32219346 _ZL17default_terminatev + 18
5   libobjc.A.dylib                 0x31568350 _objc_terminate + 140
6   libc++abi.dylib                 0x322193be _ZL19safe_handler_callerPFvvE + 70
7   libc++abi.dylib                 0x3221944a std::terminate() + 14
8   libc++abi.dylib                 0x3221a81e __cxa_rethrow + 82
9   libobjc.A.dylib                 0x315682a2 objc_exception_rethrow + 6
10  CoreFoundation                  0x37449506 CFRunLoopRunSpecific + 398
11  CoreFoundation                  0x37449366 CFRunLoopRunInMode + 98
12  UIKit                           0x30658864 -[UIApplication _run] + 544
13  UIKit                           0x30655cce UIApplicationMain + 1074
14  Company                         0x000df5d8 0xde000 + 5592
15  Company                         0x000df590 0xde000 + 5520

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x328883a8 kevent + 24
1   libdispatch.dylib               0x346a5f04 _dispatch_mgr_invoke + 708
2   libdispatch.dylib               0x346a5c22 _dispatch_mgr_thread + 30

Thread 2:
0   libsystem_kernel.dylib          0x32898cd4 __workq_kernreturn + 8
1   libsystem_c.dylib               0x34bc8f36 _pthread_wqthread + 610
2   libsystem_c.dylib               0x34bc8cc8 start_wqthread + 0

Thread 3:
0   libsystem_kernel.dylib          0x32898cd4 __workq_kernreturn + 8
1   libsystem_c.dylib               0x34bc8f36 _pthread_wqthread + 610
2   libsystem_c.dylib               0x34bc8cc8 start_wqthread + 0

Thread 4 name:  WebThread
Thread 4:
0   libsystem_kernel.dylib          0x328980d8 __psynch_mutexwait + 24
1   libsystem_c.dylib               0x34bc2674 pthread_mutex_lock + 376
2   WebCore                         0x336994e8 _ZL17_WebTryThreadLockb + 208
3   WebCore                         0x336997ec _ZL14WebRunLoopLockP19__CFRunLoopObservermPv + 24
4   CoreFoundation                  0x374c7b14 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 12
5   CoreFoundation                  0x374c5d50 __CFRunLoopDoObservers + 252
6   CoreFoundation                  0x374c616a __CFRunLoopRun + 946
7   CoreFoundation                  0x3744949e CFRunLoopRunSpecific + 294
8   CoreFoundation                  0x37449366 CFRunLoopRunInMode + 98
9   WebCore                         0x3373cc9c _ZL12RunWebThreadPv + 396
10  libsystem_c.dylib               0x34bce72e _pthread_start + 314
11  libsystem_c.dylib               0x34bce5e8 thread_start + 0

Thread 5:
0   libsystem_kernel.dylib          0x32898cd4 __workq_kernreturn + 8
1   libsystem_c.dylib               0x34bc8f36 _pthread_wqthread + 610
2   libsystem_c.dylib               0x34bc8cc8 start_wqthread + 0

Thread 0 crashed with ARM Thread State:
r0: 0x00000000    r1: 0x00000000      r2: 0x00000001      r3: 0x00000000
r4: 0x00000006    r5: 0x3f18dd98      r6: 0x00000002      r7: 0x2fedca68
r8: 0x0c641d30    r9: 0x00000000     r10: 0x0c63fd00     r11: 0x3fae9728
ip: 0x00000148    sp: 0x2fedca5c      lr: 0x34c0d20f      pc: 0x3289832c

cpsr: 0x000f0010

The line

"2 CoreData   0x324ee491 -[NSManagedObjectModel(_NSInternalMethods) _setIsEditable:] + 1" 

indicates some problem with the core data but I do not know what nor what I need to do to fix this. Any idea?

iphone
core-data
crash
migration
asked on Stack Overflow Feb 14, 2013 by EmmKay • edited Feb 14, 2013 by gustavodidomenico

1 Answer

0

I found the issue after much time spent.

The ipa file was being built using a build script and this was caused by a build error.

The built .ipa file did not include the second version of core data. So the app always crashed.

answered on Stack Overflow Mar 25, 2013 by EmmKay

User contributions licensed under CC BY-SA 3.0