siteline / swiftui-introspect

Introspect underlying UIKit/AppKit components from SwiftUI
MIT License
5.39k stars 334 forks source link

Swift 6 complete concurrency warnings #418

Open GeorgeElsham opened 3 weeks ago

GeorgeElsham commented 3 weeks ago

Description

After updating to Swift 6 with complete concurrency checking following Migrate your app to Swift 6, I am getting multiple warnings. One on a List looks like so:

Static property 'v17' is not concurrency-safe because non-'Sendable' type 'PlatformViewVersion<iOSVersion, ListType, UICollectionView>' may have shared mutable state; this is an error in the Swift 6 language mode

Checklist

Expected behavior

It should compile with no warnings or errors.

Actual behavior

Xcode produces warnings.

Steps to reproduce

Example code:

.introspect(.list, on: .iOS(.v17)) { list in
    /* ... */
}

Version information

1.1.4

Destination operating system

iOS 18.0

Xcode version information

Version 16.0 beta (16A5171c)

Swift Compiler version information

swift-driver version: 1.109.2 Apple Swift version 6.0 (swiftlang-6.0.0.3.300 clang-1600.0.20.10)
Target: arm64-apple-macosx14.0
tscdl commented 2 weeks ago

As an intermediate workaround, I think you can put this somewhere in your top level code. However, not sure if it´s correct.

extension iOSViewVersion<ScrollViewType, UIScrollView> {
    nonisolated(unsafe) public static let v17 = Self(for: .v17)
}
Alex293 commented 2 weeks ago

I’ll work on this today after a brief attempt this is easily achievable by stabbing some Sendable conformances and annotating most things with main actor. There is one thing that might be tricky, the debug helper.

First quick draft: #422