Hi all,
I’m hitting what looks like a strict-concurrency isolation issue when using UITableViewDiffableDataSource 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 'BasketSection' to 'Hashable' cannot satisfy conformance requirement for a 'Sendable' type parameter 'SectionIdentifierType'
• Similar error for Fruit as ItemIdentifierType
• Also occasionally - Failed to produce diagnostic for expression; please submit a bug report
What confused me
I expected this to compile since:
• BasketSection and Fruit are plain value types (enum/struct)
• both conform to Hashable + Sendable
• UI code is isolated to @MainActor
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)?