我们应用的第一个版本在应用商店。为了使应用程序国际化,对应用程序使用的核心数据模型进行了一个小的更改,更改是 - 添加到其中一个实体的新属性。
我通过向核心数据添加新的版本控制模型并将当前的核心数据模型设置为创建的新版本来进行更改。
为了进行轻量级迁移,我添加了所需的选项,如下所示:
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];
在模拟器中进行测试并在设备上进行测试时(连接到 MAC 时),所有这些都可以正常工作。一旦我制作了一个 ipa 文件并将其安装在设备上,应用程序就会在我启动它时立即崩溃。default.png 文件显示,然后没有加载其他视图。
应用程序崩溃日志显示 CoreData 存在一些问题,但我无法说出这是导致问题的原因。崩溃日志如下所示:
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
线
"2 CoreData 0x324ee491 -[NSManagedObjectModel(_NSInternalMethods) _setIsEditable:] + 1"
表明核心数据存在一些问题,但我不知道我需要做什么或做什么来解决这个问题。任何想法?