SwiftData and CloudKit Issues

Hi, I'm using SwiftData in my app, and I want to sent data to iCloud with CloudKit, but I found that If the user turns off my App iCloud sync function in the settings App, the local data will also be deleted. A better way is maintaining the local data, just don't connect to iCloud.How should I do that?

I need guidance!!! I'm just getting started with CloudKit

And I would be appreciated!

SwiftData + CloudKit integration uses NSPersistentCloutKitContainer under the hood, and it is intentional that the framework deletes the local data when the user turns off iCloud for the app in Settings. The behavior is discussed in this post. Feel free to follow up here with further questions, if any.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

SwiftData and CloudKit Issues
 
 
Q