使用 Fabrics 崩溃分析或“Crashlytics”我从以下方法/属性中得到大量崩溃(我假设 BAD_ACCESS):
lazy var managedObjectModel: NSManagedObjectModel = {
// The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
var modelURL = NSBundle.mainBundle().URLForResource("<app_name>", withExtension: "momd")
return NSManagedObjectModel(contentsOfURL: modelURL!)!
}()
大量我的意思是 150 名用户在一天内发生了 275 次崩溃。它在大多数设备上都可以正常工作,但是我的模拟器确实遇到过一次问题,我重置了内容并重新启动了我的机器,错误就消失了。
我希望有一个更好的解决方案,而不是告诉那些打电话给我们技术支持的人。
面料退回
Crashed: com.apple.main-thread
0 <app_name> 0x100082f9c specialized AppDelegate.(persistentStoreCoordinator.getter).(closure #1) (AppDelegate.swift:314)
1 <app_name> 0x10007e678 AppDelegate.saveContext() -> () (AppDelegate.swift:340)
2 <app_name> 0x10007e014 @objc AppDelegate.applicationWillTerminate(UIApplication) -> () (AppDelegate.swift)
3 UIKit 0x1949f0d48 -[UIApplication _terminateWithStatus:] + 244
4 UIKit 0x194bef268 __102-[UIApplication _handleApplicationDeactivationWithScene:shouldForceExit:transitionContext:completion:]_block_invoke.2093 + 792
5 UIKit 0x194bf2a18 _runAfterCACommitDeferredBlocks + 292
6 UIKit 0x194be4ab4 _cleanUpAfterCAFlushAndRunDeferredBlocks + 528
7 UIKit 0x194958724 _afterCACommitHandler + 132
8 CoreFoundation 0x18e7e49a0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
9 CoreFoundation 0x18e7e2628 __CFRunLoopDoObservers + 372
10 CoreFoundation 0x18e7e2a74 __CFRunLoopRun + 956
11 CoreFoundation 0x18e712d94 CFRunLoopRunSpecific + 424
12 GraphicsServices 0x19017c074 GSEventRunModal + 100
13 UIKit 0x1949cb130 UIApplicationMain + 208
14 <app_name> 0x100069940 main (AppDelegate.swift:43)
15 libdyld.dylib 0x18d72159c start + 4
有没有其他人遇到过这个问题?我们正在使用 Swift 2.3,目前正在转换为 Swift 3.1。
该函数在调用applicationWillTerminate()时调用。modelURL 为零。