1

Try to update my app from iOS 17 to iOS 18. I'm using SwiftData to save the data on the memory. On iOS 17 all works fine, but I tried to export my app to iOS 18, and I get a strange error when I try to delete a playlist from SwiftData memory.

Thread 10: Fatal error: Never access a full future backing data - PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: x-coredata://4885953A-BDB2-4CD1-9299-B2FBBB899EB7/PlaylistItem/p372), implementation: SwiftData.PersistentIdentifierImplementation) with Optional(B2A80504-2FE1-4C86-8341-3DDE8B6AB913)

The code where this error happen is very simple,

  func deletePlaylist(_ playlist: PlayListModel) async throws {
        print("attempt to delate :, \(playlist.playlistName)")
        context.delete(playlist)
        try context.save() // error here on the save 
    }

Error only happen on iOS 18 not on the 17.

2
  • I'm encountering this too. The behaviour of the crash changes depending on the relationships (mine are one to many) that exist in the deleted model but whatever I've tried, the crash persists. Can you show the PlayListModel?
    – Magnas
    Commented Jul 6 at 8:43
  • Note that the error is for PlaylistItem and not the PlayListModel that is shown in the code, I assume they are related? If you run this with Core Data debug logging do you see anything interesting in the logs? Commented Jul 6 at 11:23

1 Answer 1

0

I had the error too, no iCloud, iOS 18 beta 2. What fixed it for me is deleting all relationships and saving the context before I delete the parent.

for parent in parentsToDelete {
    for child in parent.childs {
        context.delete(child)
    }
    try context.save()
    context.delete(parent)
}
try context.save()

Not the answer you're looking for? Browse other questions tagged or ask your own question.