Harmony
Harmony copied to clipboard
Multiple model variables that include ID interfere with CloudKit sync.
If the user has a model that has more than one object in which has the word ID or id in it, the func nextRecordZoneChangeBatch on Line 192, the return on Line 206 will return a null record. This means that there will be no CloudKit sync possible and there is no specific error reflecting this.
Unsure if this is relevant to #3.
// Bad Model
struct Achievement: HRecord, Codable, Identifiable, Hashable {
var id: UUID = UUID()
var achievementID: String
var zoneID: CKRecordZone.ID {
return CKRecordZone.ID(
zoneName: "Achievement",
ownerName: CKCurrentUserDefaultName
)
}
var archivedRecordData: Data?
var record: CKRecord {
let encoder = CKRecordEncoder(zoneID: zoneID)
return try! encoder.encode(self)
}
}
// Acceptable Model
struct Achievement: HRecord, Codable, Identifiable, Hashable {
var id: UUID = UUID()
var achievementType: String
var zoneID: CKRecordZone.ID {
return CKRecordZone.ID(
zoneName: "Achievement",
ownerName: CKCurrentUserDefaultName
)
}
var archivedRecordData: Data?
var record: CKRecord {
let encoder = CKRecordEncoder(zoneID: zoneID)
return try! encoder.encode(self)
}
}
I'll see if I can replicate this in the near future. Definitely some more checks could be added.
Are there any insights to this? I currently have no access to a paid developer account so I can't test this behaviour but I am wondering whether this is related to the recordID parsing or the CloudKit Codable implementation. I am currently looking at your package as one way for me to add syncing to a future app but I would like more insights on this bug as I think it could easily trip me up in the future.
@dehlen I haven't dived deep into this bug as of yet to reproduce it and confirm it is an active bug still.
Based on my testing, this does not occur within my own project where I have variables named with iD within them. It shouldn't conflict in theory.
Closing for now.