Rename CKRecord.setValue overload to setBytes to fix unexpected Xcode 26.4 overload resolution#425
Rename CKRecord.setValue overload to setBytes to fix unexpected Xcode 26.4 overload resolution#425jsutula wants to merge 1 commit intopointfreeco:mainfrom
Conversation
… 26.4 overload resolution
| case .blob(let value): | ||
| setValue(value, forKey: column.name, at: userModificationTime) | ||
| setBytes(value, forKey: column.name, at: userModificationTime) |
There was a problem hiding this comment.
@stephencelis I was hoping the impact of this bug would be in tests only, but I had to change this line here in CKRecord.update to fix things, and unfortunately it's called by SyncEngine. I believe this means that anyone who's already been building/running/deploying with Xcode 26.4 will have to contend with this behavioral change having impacted how data is stored (blobs directly in the record vs CKAsset), and address any side effects stemming from that. Can you confirm if this is something we need to be concerned about?
I also see that you made the change to support Xcode 26.4 last month with release 1.6.0. Were the tests passing with early Xcode 26.4 betas? I jumped straight from 26.3 to 26.4 RC, so it's possible the behavior change may have been introduced in a later beta build or RC.
Problem
Unit tests are failing with Xcode 26.4 (I'm on Xcode 26.4 RC 17E192).
When calling
CKRecord.setValue(_ newValue:forKey:at)with a value of bytes ([UInt8]), building with Xcode 26.4 results in an unexpectedsetValueoverload being invoked, causing test failures inSchemaChangeTestsandAssetsTests.With Xcode 26.3, the expected overload accepting
[UInt8]is invoked. This overload saves the bytes in aCKAssetand then saves the asset as a regular field on the record.sqlite-data/Sources/SQLiteData/CloudKit/CloudKit+StructuredQueries.swift
Lines 193 to 194 in 65502ac
With Xcode 26.4, the overload accepting
some CKRecordValueProtocol & Equatableis invoked instead. This overload writes the value directly toencryptedValues, noCKAsset.sqlite-data/Sources/SQLiteData/CloudKit/CloudKit+StructuredQueries.swift
Lines 154 to 155 in 65502ac
Solution
Rename the overload which accepts bytes to
setBytesand update all callers. The new name sidesteps the compiler having to resolve the overload and better reflects there being a distinct behavioral difference compared to plainsetValue.Testing
With Xcode 26.4 selected,
swift test. All tests pass including previously failingSchemaChangeTestsandAssetsTests.