2016-07-18 6 views
1

Mein App Store-Update-Build stürzt ab, es ist ein Kerndatenabsturz, aber ich bekomme diesen Absturz nur auf iOS 8-Geräten, funktioniert auf iOS einwandfrei 9 Geräte. Ich habe die Lightweight-Migration korrekt durchgeführt und die neue Modellversion hinzugefügt, wobei die alte Version als Basis beibehalten wurde. Außerdem wurde das Wörterbuch in den Optionen hinzugefügt, während "addPersistentStoreWithType" hinzugefügt wurde.Kerndatenmigration - Absturz von Appstore auf iOS 8-Geräten unter iOS 9

ManagedObjectModel

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. 
    let modelURL = NSBundle.mainBundle().URLForResource("abcProject", withExtension: "momd") 
    NSLog("Url is - \(modelURL)") 
    return NSManagedObjectModel(contentsOfURL: modelURL!)! 
}() 

PersistentStoreCoordinator

lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = { 
    var coordinator: NSPersistentStoreCoordinator? = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel) 
    let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("abcProject") 
    var error: NSError? = nil 
    var failureReason = "There was an error creating or loading the application's saved data." 
    do { 
     let mOptions = [NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true] 
     NSLog("TEST564 - 7 URL - \(url)") 
     try coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: mOptions) 
    } catch var error1 as NSError { 
     error = error1 
     coordinator = nil 
     // Report any error we got. 
     var dict = [String: AnyObject]() 
     dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data" 
     dict[NSLocalizedFailureReasonErrorKey] = failureReason 
     dict[NSUnderlyingErrorKey] = error 
     error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict) 
     // Replace this with code to handle the error appropriately. 
     // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 
     NSLog("TEST564 Unresolved error \(error), \(error!.userInfo)") 
     abort() 
    } catch { 
     fatalError() 
     NSLog("TEST564 FATAL error") 

    } 

    return coordinator 
}() 

Oben ist mein Set Referenz Code. Ich habe überall gesucht und bekomme nur Details über die leichte Migration.

Es folgt das Geräteprotokoll nach Absturz: -

> Jul 19 11:25:00 iPhone abcProject-Production[211] <Warning>: CoreData: error: -addPersistentStoreWithType:SQLite configuration:(null) 

URL:file:///var/mobile/Containers/Data/Application/B12FCDA6-C91B-487E-8D03-CBBEB884996D/Documents/abcProject options:{ 
NSInferMappingModelAutomaticallyOption = 1; 
NSMigratePersistentStoresAutomaticallyOption = 1; 
} ... returned error Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" 

UserInfo=0x16b05490 {URL=file:///var/mobile/Containers/Data/Application/B12FCDA6-C91B-487E-8D03-CBBEB884996D/Documents/abcProject, metadata={ 
    NSPersistenceFrameworkVersion = 519; 
    NSStoreModelVersionHashes =  { 
     TabBanner = <3722cf8b 4ac58f43 20c84d7e 7d66865d a1382ecc 1ab25190 7b7c3fa7 843813fe>; 
     Video = <c51795f8 140c4936 de1b7615 03a944e7 f2b0451f 3c0b5887 2cfb31d3 07610d22>; 
    };NSStoreModelVersionHashesVersion = 3; 
    NSStoreModelVersionIdentifiers =  (
     "" 
    ); 
    NSStoreType = SQLite; 
    NSStoreUUID = "79788D63-BEF2-4339-BF60-1580904D9B44"; 
    "_NSAutoVacuumLevel" = 2; 
}, reason=Can't find model for source store} with userInfo dictionary { 
URL = "file:///var/mobile/Containers/Data/Application/B12FCDA6-C91B-487E-8D03-CBBEB884996D/Documents/abcProject"; 
metadata =  { 
    NSPersistenceFrameworkVersion = 519; 
    NSStoreModelVersionHashes =   { 
     TabBanner = <3722cf8b 4ac58f43 20c84d7e 7d66865d a1382ecc 1ab25190 7b7c3fa7 843813fe>; 
     Video = <c51795f8 140c4936 de1b7615 03a944e7 f2b0451f 3c0b5887 2cfb31d3 07610d22>; 
    }; 
    NSStoreModelVersionHashesVersion = 3; 
    NSStoreModelVersionIdentifiers =   (
     "" 
    ); 
    NSStoreType = SQLite; 
    NSStoreUUID = "79788D63-BEF2-4339-BF60-1580904D9B44"; 
    "_NSAutoVacuumLevel" = 2; 
}; 
reason = "Can't find model for source store"; 
} 


Jul 19 11:25:00 iPhone abcProject-Production[211] <Warning>: CoreData: annotation: NSPersistentStoreCoordinator's current model hashes are { 
TabBanner = <2efd2387 6f370f71 d585132f 9d6aa8fe afcdc841 ef6e9b89 396625d1 cbc99cea>; 
Video = <c51795f8 140c4936 de1b7615 03a944e7 f2b0451f 3c0b5887 2cfb31d3 07610d22>; 
} 

Jul 19 11:25:00 iPhone abcProject-Production[211] <Warning>: Unresolved error Optional(Error Domain=YOUR_ERROR_DOMAIN Code=9999 "Failed to initialize the application's saved data" UserInfo=0x168e0c90 {NSLocalizedDescription=Failed to initialize the application's saved data, NSUnderlyingError=0x16b05350 "The operation couldn’t be completed. (Cocoa error 134130.)", NSLocalizedFailureReason=There was an error creating or loading the application's saved data.}), [NSLocalizedDescription: Failed to initialize the application's saved data, NSUnderlyingError: Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" 

UserInfo=0x16b05490 {URL=file:///var/mobile/Containers/Data/Application/B12FCDA6-C91B-487E-8D03-CBBEB884996D/Documents/abcProject, metadata={ 
NSPersistenceFrameworkVersion = 519; 
NSStoreModelVersionHashes =  { 
    TabBanner = <3722cf8b 4ac58f43 20c84d7e 7d66865d a1382ecc 1ab25190 7b7c3fa7 843813fe>; 
    Video = <c51795f8 140c4936 de1b7615 03a944e7 f2b0451f 3c0b5887 2cfb31d3 07610d22>; 
}; 

NSStoreModelVersionHashesVersion = 3; 
NSStoreModelVersionIdentifiers =  (
    "" 
); 

NSStoreType = SQLite; 
NSStoreUUID = "79788D63-BEF2-4339-BF60-1580904D9B44"; 
"_NSAutoVacuumLevel" = 2; 
}, reason=Can't find model for source store}, NSLocalizedFailureReason: There was an error creating or loading the application's saved data.] 
Jul 19 11:25:01 iPhone ReportCrash[212] <Error>: task_set_exception_ports(B07, 400, D03, 0, 0) failed with error (4: (os/kern) invalid argument) 

Jul 19 11:25:01 iPhone ReportCrash[212] <Notice>: ReportCrash acting against PID 211 

Jul 19 11:25:01 iPhone ReportCrash[212] <Notice>: Formulating crash report for process abcProject-Production[211] 

Jul 19 11:25:01 iPhone SpringBoard[43] <Warning>: BSXPCMessage received error for message: Connection invalid 

Jul 19 11:25:01 iPhone SpringBoard[43] <Warning>: Unable to get short BSD proc info for 211: No such process 

Jul 19 11:25:01 iPhone SpringBoard[43] <Warning>: Unable to get short BSD proc info for 211: No such process 

Jul 19 11:25:01 iPhone mediaserverd[37] <Notice>: '' com.abcProject(pid = 211) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None 

Jul 19 11:25:01 iPhone wifid[69] <Notice>: WiFi:[490600501.266659]: Foreground Network Application exited. 

Jul 19 11:25:01 iPhone AppStore[175] <Warning>: [SSMetricsEventController] Direct-access controller is calling through XPC to flush Unreported Events 

Jul 19 11:25:01 iPhone wifid[69] <Notice>: WiFi:[490600501.267352]: BG Application: Not Present, BG Daemon: Present. Daemons: apsd itunesstored networkd 

Jul 19 11:25:01 iPhone locationd[64] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0 

Jul 19 11:25:01 iPhone com.apple.xpc.launchd[1] (UIKitApplication:com.abcProject[0xb6e0][211]) <Notice>: Service exited due to signal: Abort trap: 6 

Jul 19 11:25:01 iPhone com.apple.xpc.launchd[1] (UIKitApplication:com.abcProject[0xb6e0]) <Notice>: Service only ran for 6 seconds. Pushing respawn out by 2147483641 seconds. 

Jul 19 11:25:01 iPhone locationd[64] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0 

Jul 19 11:25:01 iPhone SpringBoard[43] <Warning>: Application 'UIKitApplication:com.abcProject[0xb6e0]' crashed. 

Jul 19 11:25:01 iPhone assertiond[58] <Warning>: pid_suspend failed for <BKNewProcess: 0x1668b480; com.abcProject; pid: 211; hostpid: -1>: Unknown error: -1, Unknown error: -1 

Jul 19 11:25:01 iPhone assertiond[58] <Warning>: Could not set priority of <BKNewProcess: 0x1668b480; com.abcProject; pid: 211; hostpid: -1> to 2, priority: No such process 

Jul 19 11:25:01 iPhone assertiond[58] <Warning>: Could not set priority of <BKNewProcess: 0x1668b480; com.abcProject; pid: 211; hostpid: -1> to 4096, priority: No such process 

Jul 19 11:25:01 iPhone UserEventAgent[17] <Warning>: id=com.abcProject pid=211, state=0 

Jul 19 11:25:01 iPhone ReportCrash[212] <Notice>: Saved report to /var/mobile/Library/Logs/CrashReporter/abcProject-Production_2016-07-19-112501_iPhone.ips 

Jul 19 11:25:06 iPhone wifid[69] <Notice>: WiFi:[490600506.681414]: WiFi unquiescing requested by "locationd" 

Jul 19 11:25:06 iPhone wifid[69] <Notice>: WiFi:[490600506.686744]: WiFi unquiescing requested by "locationd" 

Jul 19 11:25:06 iPhone wifid[69] <Notice>: WiFi:[490600506.743193]: WiFi unquiescing requested by "locationd" 

Jul 19 11:25:08 iPhone wifid[69] <Notice>: WiFi:[490600508.843256]: Client itunesstored set type to normal application 

Jul 19 11:25:08 iPhone wifid[69] <Notice>: WiFi:[490600508.844080]: __WiFiManagerSetEnableState: state TRUE, manager->enable.setting TRUE, manager->unlockedSinceBoot TRUE 

Jul 19 11:25:08 iPhone wifid[69] <Notice>: WiFi:[490600508.845449]: BG Application: Not Present, BG Daemon: Present. Daemons: apsd networkd 

Jul 19 11:25:09 iPhone locationd[64] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0 

Jul 19 11:25:12 iPhone aggregated[29] <Warning>: Scheduling parameters: 0 minutes before midnight, 4.0 time(s)/day 

Jul 19 11:25:12 iPhone aggregated[29] <Warning>: delay: 595 into interval 21600 => 22195 

Jul 19 11:25:12 iPhone aggregated[29] <Warning>: Next ADDaily run scheduled in 06:09:55 at 2016-07-19 12:05:07 +0000 

Jul 19 11:25:12 iPhone addaily[213] <Warning>: addaily started 

Jul 19 11:25:12 iPhone addaily[213] <Warning>: daily tasks for day 17000 

Jul 19 11:25:13 iPhone addaily[213] <Warning>: Filtering only beta sessions 

Jul 19 11:25:13 iPhone addaily[213] <Warning>: Saved Sessions as /var/mobile/Library/Logs/CrashReporter/log-sessions-2016-07-19-112513.session 

Jul 19 11:25:23 iPhone addaily[213] <Warning>: addaily ended 
+0

Haben Sie irgendwelche Details über den Absturz? Im Moment ist noch nicht einmal klar, was darauf hindeutet, dass der Absturz auf eine Migration zurückzuführen ist. –

+0

Ich habe die Frage mit dem vollständigen Geräteprotokollabsturz nach der Installation bearbeitet. Bitte werfen Sie einen Blick darauf und lassen Sie mich wissen, wenn Sie das Problem finden können. Dank –

+0

Ich bin auch mit demselben Problem konfrontiert.Migration funktioniert auf iOS 9-Gerät, aber Absturz auf iOS 8-Geräten. –

Antwort

0

Endlich habe ich es gelöst, indem ich eine einfache Änderung vorgenommen habe.

Früher Code: -

url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("abcProject1") 

Fest Code: -

url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("abcProject1.sqlite") 

Zugabe < .sqlite> Erweiterung auf meine URL-Pfad löste das Problem für mich. Es ist vollständig mit allen möglichen Szenarien getestet. Vielen Dank für Ihre Hilfe.

2

Der Fehler, Can't find model for source store sagt, dass, wenn die App für den permanenten Speicher zu migrieren versucht, es nicht das Datenmodell finden konnten, die verwendet worden war, Erstelle das Geschäft. Die Datenmigration erfordert sowohl den alten als auch den neuen Datenspeicher. Der alte wird verwendet, um die Daten zu laden, und der neue wird verwendet, um die Daten für die zukünftige Verwendung zu aktualisieren.

Der Grund, warum dies unter iOS 9 funktioniert, ist, dass iOS 9 Model Caching für die Verwendung in einfachen Migrationen von SQLite-Stores hinzugefügt hat. Unter iOS 9 können Sie daher eine erfolgreiche Migration ohne das alte Modell erhalten, da die alte Version automatisch zwischengespeichert wird. Diese Funktion war auf iOS 8 nicht verfügbar. Wenn Sie also weiterhin 8 unterstützen, müssen Sie die alte Version des Modells in Ihre App integrieren.

+0

Vielen Dank - Ja das ist, was ich dachte aber die Sache ist, ich habe alle Datenmodell von Anfang an, ich habe diese Migration mit den gleichen Szenarien für die anderen Projekte und sie funktionieren gut, ich bin sicher, dass es sein muss ein kleines Problem darin. –

+0

Bitte sehen Sie meine Antwort, Wenn Sie mir sagen könnten, warum es richtig funktioniert? –

-1

Um den Absturz zu vermeiden, habe ich eine neue Datenbank für iOS 8 erstellt, weil ich nicht so viele Daten benötigt.

Ich änderte meine storeURL von

let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("abcProject") 

zu

let url:NSURL 
if (OS_VERSION<9.0) 
{ 
    url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("abcProject1") 
} 
else 
{ 
    url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("abcProject") 
} 

Das ist für mich die Absturzfehler behoben.

+0

Danke, aber ich brauche die vorhandenen Daten damit ich das nicht nutzen kann. –