SwiftUI automatic refresh of Coudkit data

Viewed 185

I'm using CloudKit to store my data but now I have to close the app every time something changed. With @FetchRequest this should be automatic, shouldn't it?

@FetchRequest(
    sortDescriptors: [NSSortDescriptor(keyPath: \Exercise.createdAt, ascending: true)],
    animation: .default)

private var exercises: FetchedResults<Exercise>
1 Answers

Make sure your have enabled Push and remote notifications per the Apple Documentation

Project Settings > Signing and Capabilities 

Sync CoreData with CloudKit using

try? persistentContainer.viewContext.setQueryGenerationFrom(.current)
Related