CoreData CKRecord, Sendable & Async

When I run Apple's Sample Code

Such as:

Xcode issues a bunch of warnings including:

  • Capture of 'savedRecord' with non-sendable type 'CKRecord' in a @Sendable closure
  • Non-sendable type '[CKRecordZone]' passed in implicitly asynchronous call to main actor-isolated function cannot cross actor boundary
  • Non-sendable type 'CKRecordZone' in asynchronous access to main actor-isolated property 'recordZone' cannot cross actor boundary

Can I rely on this sample code for how to do it for production apps or am I going to run into issues with data consistency, etc?

Aside from ignoring these warnings (or even hiding them), is there anything I can do about them?

Is there a better way to now use CoreData with Async/Await than what the Apple sample code is showing?

Answered by CaliforniaJay in 751527022

This morning on Apple's Git hub for cloudkit-privateddb-sync was updated with a fix for this problem. "CKRecorddoes not yet conform toSendable`, so to avoid it crossing the actor boundary we pull out what we need from changed/new records before." see changes here: https://github.com/apple/sample-cloudkit-privatedb-sync/commit/b00e00e57c879690af6654c59982d073b5d29de1

I'm hoping that cloud kit-sharing will be updated with similar fixes soon.

I have the same problem and I can't find any answers

Accepted Answer

This morning on Apple's Git hub for cloudkit-privateddb-sync was updated with a fix for this problem. "CKRecorddoes not yet conform toSendable`, so to avoid it crossing the actor boundary we pull out what we need from changed/new records before." see changes here: https://github.com/apple/sample-cloudkit-privatedb-sync/commit/b00e00e57c879690af6654c59982d073b5d29de1

I'm hoping that cloud kit-sharing will be updated with similar fixes soon.

CoreData CKRecord, Sendable & Async
 
 
Q