Wednesday, January 4, 2023
HomeiOS Developmentios - Why MagicalRecord crashes just for some gadgets, however not for...

ios – Why MagicalRecord crashes just for some gadgets, however not for everybody?


that is my crash report from Xcode:

enter image description here

And it occurs EVERY SINGLE TIME for some gadgets (I do know it from my customers).
For my machine iPhone 13 Professional, ios 16.1 it doesnt occur in any respect.

Right here is stack hint of this situation:

Thread 0 identify:
Thread 0 Crashed:
0   libswiftCore.dylib              0x0000000198da120c _assertionFailure(_:_:file:line:flags:) + 312 (AssertCommon.swift:143)
1   libswiftCore.dylib              0x0000000198e173f0 swift_unexpectedError + 648 (ErrorType.swift:188)
2   FieldService                    0x0000000102eb8648 specialised static MagicalRecord.mr_setupCoreDataStack() + 1276 (MagicalRecord+Extension.swift:26)
3   FieldService                    0x0000000102de939c static MagicalRecord.mr_setupCoreDataStack() + 4 (:0)
4   FieldService                    0x0000000102de939c AppDelegate.utility(_:didFinishLaunchingWithOptions:) + 52 (AppDelegate.swift:123)
5   FieldService                    0x0000000102dea7b0 @objc AppDelegate.utility(_:didFinishLaunchingWithOptions:) + 144 (:0)
6   UIKitCore                       0x00000001a139cf40 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 300 (UIApplication.m:2509)
7   UIKitCore                       0x00000001a139c664 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 2848 (UIApplication.m:2940)

Here’s what I’ve in MagicalRecord+Extension.swift:26

extension MagicalRecord {

static func mr_setupCoreDataStack() {
    
    guard NSPersistentStoreCoordinator.mr_default() == nil else {
        return
    }
    
    let managedObjectModel = NSManagedObjectModel.mr_default()
    let persistentStoreCoordinator = NSPersistentStoreCoordinator(managedObjectModel: managedObjectModel!)
    
    var storePath = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: SharedGroupName)
    
    storePath = storePath!.appendingPathComponent("FieldService.sqlite")
    
    let choices = [NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true]
    // 26 th line beneath
    strive! persistentStoreCoordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: storePath, choices: choices)
    
    NSPersistentStoreCoordinator.mr_setDefaultStoreCoordinator(persistentStoreCoordinator)
    NSManagedObjectContext.mr_initializeDefaultContext(with: persistentStoreCoordinator)
}
}

Okay, I perceive that power strive might trigger a crash, possibly storePath, possibly choices. However please inform me:

Why it occur ONLY for particular gadgets, not for everybody, however for fairly variety of them? Please, do you’ve any concepts?

On my machine, and after I run the app on simulators iPhone 11, 12, 13 for iOS 15 and 16 I can not reproduce it🤷🏼‍♂️ Please, assist.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments