Post

Replies

Boosts

Views

Activity

An error occurred during persistent store migration (CoreData)
I added new model version and select it like default one. Then I added new attribute to existing entity in new model version. To test migration I installed previous version of app and add filled with all data in app. Then I install new changes and it work on simulator. If I move that build to TestFlight and test via real device then I get this error: Fatal error: ###persistentContainer: Failed to load persistent stores:Error Domain=NSCocoaErrorDomain Code=134110 "An error occurred during persistent store migration." UserInfo={sourceURL=file:///private/var/mobile/Containers/Shared/AppGroup/DBB80C75-1B07-4318-8BA3-3F4FFC14FBD7/AppName.sqlite, reason=Cannot migrate store in-place: near "null": syntax error, destinationURL=file:///private/var/mobile/Containers/Shared/AppGroup/DBB80C75-1B07-4318-8BA3-3F4FFC14FBD7/AppName.sqlite, NSUnderlyingError=0x281958180 {Error Domain=NSCocoaErrorDomain Code=134110 "An error occurred during persistent store migration." UserInfo={reason=near "null": syntax error, NSSQLiteErrorDomain=1, NSUnderlyingException=near "null": syntax error}}} I need to use CoreData for Widget's target as well. Code is here : final class CoreDataStack {     static let shared = CoreDataStack()     var context: NSManagedObjectContext { persistentContainer.viewContext }     var container: NSPersistentContainer { persistentContainer }     private let containerName = "AppName"     private var persistentContainer: NSPersistentContainer!     // MARK: - Setup     func setup() {         guard let storeURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "app_group")?.appendingPathComponent(containerName + ".sqlite") else {             fatalError("Error finding Model from File Manager")         }         let container = NSPersistentContainer(name: containerName)         let description = NSPersistentStoreDescription(url: storeURL)         description.type = NSSQLiteStoreType         description.shouldMigrateStoreAutomatically = true         description.shouldInferMappingModelAutomatically = true         container.persistentStoreDescriptions = [description]         container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy         container.viewContext.transactionAuthor = appTransactionAuthorName         container.viewContext.automaticallyMergesChangesFromParent = true         container.loadPersistentStores(completionHandler: { (_, error) in             if let error = error as NSError? {                 let crashlitycService: CrashlitycUseCase = CrashlitycService()                 crashlitycService.record(error: .errorForAnalytic(error), file: #file, function: #function, line: #line)                 fatalError("###\(#function): Failed to load persistent stores:\(error)")             }         })         self.persistentContainer = container     } } iOS 16.2 Xcode 14.1 Similar issues I found here, but without any success: https://stackoverflow.com/questions/58215343/an-error-occurring-during-core-data-persistent-store-migration-in-ios-13 https://stackoverflow.com/questions/51800871/ios-app-crashing-on-launch-screen-due-to-core-data-migration Please help me to figure out how can I do this migration?
1
0
1.2k
Feb ’23
Camera preview is missing while using torch on web view
We have QR-scanner feature implemented on web view (WKWebView). If it's dark we want to light our QR-code using flashlight in iPhone. In general, this feature works, but without flashlight. But have that problems: If we turn on torch then camera preview disappears. If turn off torch then camera preview appears. Do you have any idea why it's so? And how can we sort it out? Thanks
2
0
1.3k
Jan ’23