Swift 6 strict concurrency + UIKit DiffableDataSource: Main actor-isolated conformance ... cannot satisfy Sendable type parameter

Hi all,

I’m hitting what looks like a strict-concurrency isolation issue when using UITable​View​Diffable​Data​Source in a UIKit app under Swift 6 mode.

I can work around it, but I want to confirm the correct model and whether this is expected behavior or a compiler issue.

Environment

• Xcode: [Version 26.4.1 (17E202)]

• Swift language mode: Swift 6

• iOS deployment target: [iOS 26.4.1]

Minimal setup

import UIKit

enum BasketSection: Hashable, Sendable {
    case main
}

struct Fruit: Hashable, Identifiable, Sendable {
    let id = UUID()
    let name: String
}

@MainActor
final class ViewController: UIViewController {
    private var dataSource: UITableViewDiffableDataSource<BasketSection, Fruit>!

    private func updateDataSource() {
        var snapshot = NSDiffableDataSourceSnapshot<BasketSection, Fruit>()
        snapshot.appendSections([.main])
        snapshot.appendItems([Fruit(name: "Apple")])
        dataSource.apply(snapshot)
    }
}

Errors I get

• Main actor​-isolated conformance of '​Basket​Section' to '​Hashable' cannot satisfy conformance requirement for a '​Sendable' type parameter '​Section​Identifier​Type'

• Similar error for Fruit as Item​Identifier​Type

• Also occasionally - Failed to produce diagnostic for expression; please submit a bug report

What confused me

I expected this to compile since:

• Basket​Section and Fruit are plain value types (enum/struct)

• both conform to Hashable + Sendable

• UI code is isolated to @​Main​Actor

But the compiler still reports actor-isolated conformance issues for generic parameters used by diffable datasource/snapshot.

Workarounds that made it compile

1. Added nonisolated to both section and model type

Questions

1. Is this expected in Swift 6 strict concurrency, or a compiler bug/regression?

2. Is nonisolated on plain model types the recommended workaround here, or should it be avoided?

3. Is there a better canonical pattern for UIKit diffable datasource identifiers under strict concurrency?

4. Does the Failed to produce diagnostic indicate this should be filed as a compiler bug (with reduced repro)?

Try changing "default actor isolation" to non isolated.


Minimal test with no UIKit dependency:

enum S: Hashable, Sendable {}

struct Test<T: Hashable & Sendable> {}

@MainActor var x: Test<S>!

// default isolation MainActor: 🛑 Error: Main actor-isolated conformance of 'S' to 'Hashable' cannot satisfy conformance requirement for a 'Sendable' type parameter 'T'
// default isolation nonisolated: ✅
2 Likes

Yeah, that's what I mentioned. I need mark the section and item models as nonisolated. But is this how it's supposed to be all the time ?!

I don't know. I personally try to stay away from default actor isolation main actor, so did not test that mode often.

2 Likes

Okay, that's interesting. I just noticed that all the recently created projects' default actor isolation is set to be MainActor out of the box. It was not the case previously as far as I know.

That's right. This is a new mode available in Swift 6.2 and it is enabled by default starting with Xcode 26.

And as you've experienced, not all types should be @MainActor. So when using this mode the programmer must be aware of this and know when to use nonisolated.

3 Likes