Understand which records can be shared via CloudKit
mainIn SQLiteData, only root records can be directly shared. A root record is defined as a table that has no foreign keys.
If you attempt to call SyncEngine/share(record:configure:) with a non-root record (a record that contains foreign keys pointing to other tables), the system will throw an error. This restriction exists because sharing a child record without sharing its parent would create logical inconsistencies in data ownership and synchronization.
Examples:
- Root Record: A
RemindersListtable with only anidandtitle. - Non-Root Record: A
Remindertable that contains aremindersListIDforeign key.
To share data associated with a non-root record, you must share its parent root record instead.
@Table
struct RemindersList: Identifiable {
let id: UUID
var title = ""
}
@Table
struct Reminder: Identifiable {
let id: UUID
var title = ""
var isCompleted = false
var remindersListID: RemindersList.ID // This makes Reminder a non-root record
}