Hello all,
I'm facing the same issue - works fine on iOS 17. Crash on iOS 18 beta 5 (iOS and Xcode). Happens on device and simulator (tested on these platforms - iPhone, iPad, watchOS)
I have the following SwiftData structure. CloudKit configuration -
Room
Session
ModelContext activity is handled on SwiftUI view (create model, insert, save)
Room has cascade array of Session.
Initial state: No sessions.
Create new session and append it to room's sessions.
Delete the session.
I check the state now - room is exist with empty sessions, as expected
Create a new one.
Crash on -
_$observationRegistrar.access(self, keyPath: \.room)
return self.getValue(forKey: \.room)
}
I print the PersistentIdentifier before the crash and everything seems to be ok -
PersistentIdentifier(id: CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate managedObjectContextSaved:]: <NSCloudKitMirroringDelegate: 0x303ab00f0>: Observed context save: <NSPersistentStoreCoordinator: 0x302ea1ce0> - <NSManagedObjectContext: 0x303ea5110>
SwiftData.PersistentIdentifier.ID(url: x-coredata://ED065B2F-2704-46AD-88E1-4F1BE2BA7098/Session/p44), implementation: CoreData: CloudKit: CoreData+CloudKit: -[PFCloudKitExporter analyzeHistoryInStore:withManagedObjectContext:error:]: <PFCloudKitExporter: 0x302598370>: Exporting changes since (0): <NSPersistentHistoryToken - {
SwiftData.PersistentIdentifierImplementation)
SwiftData.PersistentModel.persistentModelID.getter : SwiftData.PersistentIdentifier
PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: x-coredata://ED065B2F-2704-46AD-88E1-4F1BE2BA7098/Room/p8), implementation: SwiftData.PersistentIdentifierImplementation)
PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: x-coredata://ED065B2F-2704-46AD-88E1-4F1BE2BA7098/Room/p8), implementation: SwiftData.PersistentIdentifierImplementation)
After the crash I open my app again, the session appears and everything works as expected.
Hope this helps.
Thanks a lot,
Dudi