Type ReferenceWritableKeyPath does not conform to the 'Sendable' protocol

This is not a question but more of a hint where I was having trouble with. In my SwiftData App I wanted to move from Swift 5 to Swift 6, for that, as recommended, I stayed in Swift 5 language mode and set 'Strict Concurrency Checking' to 'Complete' within my build settings.

It marked all the places where I was using predicates with the following warning:

Type '' does not conform to the 'Sendable' protocol; this is an error in the Swift 6 language mode

I had the same warnings for SortDescriptors.

I spend quite some time searching the web and wrapping my head around how to solve that issue to be able to move to Swift 6. In the end I found this existing issue in the repository of the Swift Language https://github.com/swiftlang/swift/issues/68943. It says that this is not a warning that should be seen by the developer and in fact when turning Swift 6 language mode on those issues are not marked as errors.

So if anyone is encountering this when trying to fix all issues while staying in Swift 5 language mode, ignore those, fix the other issues and turn on Swift 6 language mode and hopefully they are gone.

Answered by DTS Engineer in 839126022

Or, with today’s XCode (16.2), you can turn on the SWIFT_UPCOMING_FEATURE_INFER_SENDABLE_FROM_CAPTURES building setting to calm down the warning, as shown in the attached screenshot, if you are still on Swift 5.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

I'm encountering the same warning. Xcode Version 16.1 (16B40) - RC. My project settings are Swift 6 and SWIFT_STRICT_CONCURRENCY=Complete or Targeted.

The only configuration that seems to avoid this warning is SWIFT_STRICT_CONCURRENCY=Minimal.

Or, with today’s XCode (16.2), you can turn on the SWIFT_UPCOMING_FEATURE_INFER_SENDABLE_FROM_CAPTURES building setting to calm down the warning, as shown in the attached screenshot, if you are still on Swift 5.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

I ran into the same error message when using #Predicate in SwiftData @Query with

  • Xcode 26.0 beta 2,
  • "Swift Language Version" Swift 6,
  • and Setting "Default Actor Isolation" on MainActore (section Swift Compiler - Concurrency).

Setting the "Default Actor Isolation" to nonisolated and inserting @MainActor above @Observable inside the code resolved the problem.

Type ReferenceWritableKeyPath does not conform to the 'Sendable' protocol
 
 
Q