Stopping certain data models from syncing to cloudkit

Hi all,

I am using SwiftData and cloudkit and I am having an extremely persistent bug.

I am building an education section on a app that's populated with lessons via a local JSON file. I don't need this lesson data to sync to cloudkit as the lessons are static, just need them imported into swiftdata so I've tried to use the modelcontainer like this:

    static func createSharedModelContainer() -> ModelContainer {
         // --- Define Model Groups ---
        let localOnlyModels: [any PersistentModel.Type] = [
            Lesson.self, MiniLesson.self,
            Quiz.self, Question.self
        ]
        let cloudKitSyncModels: [any PersistentModel.Type] = [
            User.self, DailyTip.self, UserSubscription.self,
            UserEducationProgress.self // User progress syncs
        ]

However, what happens is that I still get Lesson and MiniLesson record types on cloudkit and for some reason as well, whenever I update the data models or delete and reinstall the app on simulator, the lessons duplicate (what seems to happen is that a set of lessons comes from the JSON file as it should), and then 1-2 seconds later, an older set of lessons gets synced from cloudkit.

I can delete the old set of lessons if I just delete the lessons and mini lessons record types, but if I update the data model again, this error reccurrs.

Sorry, I don't know if I managed to explain this well but essentially I just want to stop the lessons and minilessons from being uploaded to cloudkit as I think this will fix the problem. Am I doing something wrong with the code?

Stopping certain data models from syncing to cloudkit
 
 
Q