Skip to content

Commit da67233

Browse files
committed
Make the rest actually work in Swift 6
1 parent 8a331b6 commit da67233

9 files changed

+20
-18
lines changed

Sources/Introspect.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import SwiftUI
44
/// The scope of introspection i.e. where introspect should look to find
55
/// the desired target view relative to the applied `.introspect(...)`
66
/// modifier.
7-
public struct IntrospectionScope: OptionSet {
7+
public struct IntrospectionScope: OptionSet, Sendable {
88
/// Look within the `receiver` of the `.introspect(...)` modifier.
99
public static let receiver = Self(rawValue: 1 << 0)
1010
/// Look for an `ancestor` relative to the `.introspect(...)` modifier.
@@ -96,6 +96,7 @@ struct IntrospectModifier<SwiftUIViewType: IntrospectableViewType, PlatformSpeci
9696
}
9797
}
9898

99+
@MainActor
99100
public protocol PlatformEntity: AnyObject {
100101
associatedtype Base: PlatformEntity
101102

Sources/IntrospectionSelector.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public struct IntrospectionSelector<Target: PlatformEntity>: Sendable {
55
public static var `default`: Self { .from(Target.self, selector: { $0 }) }
66

77
@_spi(Advanced)
8-
public static func from<Entry: PlatformEntity>(_ entryType: Entry.Type, selector: @escaping (Entry) -> Target?) -> Self {
8+
public static func from<Entry: PlatformEntity>(_ entryType: Entry.Type, selector: @MainActor @Sendable @escaping (Entry) -> Target?) -> Self {
99
.init(
1010
receiverSelector: { controller in
1111
controller.as(Entry.Base.self)?.receiver(ofType: Entry.self).flatMap(selector)

Sources/IntrospectionView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import SwiftUI
44
typealias IntrospectionViewID = UUID
55

66
fileprivate enum IntrospectionStore {
7-
static var shared: [IntrospectionViewID: Pair] = [:]
7+
@MainActor static var shared: [IntrospectionViewID: Pair] = [:]
88

99
struct Pair {
1010
weak var controller: IntrospectionPlatformViewController?
@@ -13,7 +13,7 @@ fileprivate enum IntrospectionStore {
1313
}
1414

1515
extension PlatformEntity {
16-
var introspectionAnchorEntity: Base? {
16+
@MainActor var introspectionAnchorEntity: Base? {
1717
if let introspectionController = self as? IntrospectionPlatformViewController {
1818
return IntrospectionStore.shared[introspectionController.id]?.anchor~
1919
}

Sources/PlatformView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ typealias _PlatformViewControllerRepresentable = UIViewControllerRepresentable
1919
typealias _PlatformViewControllerRepresentable = NSViewControllerRepresentable
2020
#endif
2121

22+
@MainActor
2223
protocol PlatformViewControllerRepresentable: _PlatformViewControllerRepresentable {
2324
#if canImport(UIKit)
2425
typealias ViewController = UIViewControllerType

Sources/RuntimeWarnings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func runtimeWarn(
5656
//
5757
// Feedback filed: https://gist.github.com/stephencelis/a8d06383ed6ccde3e5ef5d1b3ad52bbc
5858
@usableFromInline
59-
let dso = { () -> UnsafeMutableRawPointer in
59+
nonisolated(unsafe) let dso = { () -> UnsafeMutableRawPointer in
6060
let count = _dyld_image_count()
6161
for i in 0..<count {
6262
if let name = _dyld_get_image_name(i) {

Sources/ViewTypes/FullScreenCover.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ extension iOSViewVersion<FullScreenCoverType, UIPresentationController> {
8080
public static let v18 = Self(for: .v18, selector: selector)
8181

8282
private static var selector: IntrospectionSelector<UIPresentationController> {
83-
.from(UIViewController.self, selector: \.presentationController)
83+
.from(UIViewController.self, selector: { $0.presentationController })
8484
}
8585
}
8686

@@ -94,7 +94,7 @@ extension tvOSViewVersion<FullScreenCoverType, UIPresentationController> {
9494
public static let v18 = Self(for: .v18, selector: selector)
9595

9696
private static var selector: IntrospectionSelector<UIPresentationController> {
97-
.from(UIViewController.self, selector: \.presentationController)
97+
.from(UIViewController.self, selector: { $0.presentationController })
9898
}
9999
}
100100

@@ -103,7 +103,7 @@ extension visionOSViewVersion<FullScreenCoverType, UIPresentationController> {
103103
public static let v2 = Self(for: .v2, selector: selector)
104104

105105
private static var selector: IntrospectionSelector<UIPresentationController> {
106-
.from(UIViewController.self, selector: \.presentationController)
106+
.from(UIViewController.self, selector: { $0.presentationController })
107107
}
108108
}
109109
#endif

Sources/ViewTypes/Popover.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ extension iOSViewVersion<PopoverType, UIPopoverPresentationController> {
6565
public static let v18 = Self(for: .v18, selector: selector)
6666

6767
private static var selector: IntrospectionSelector<UIPopoverPresentationController> {
68-
.from(UIViewController.self, selector: \.popoverPresentationController)
68+
.from(UIViewController.self, selector: { $0.popoverPresentationController })
6969
}
7070
}
7171

@@ -74,7 +74,7 @@ extension visionOSViewVersion<PopoverType, UIPopoverPresentationController> {
7474
public static let v2 = Self(for: .v2, selector: selector)
7575

7676
private static var selector: IntrospectionSelector<UIPopoverPresentationController> {
77-
.from(UIViewController.self, selector: \.popoverPresentationController)
77+
.from(UIViewController.self, selector: { $0.popoverPresentationController })
7878
}
7979
}
8080
#endif

Sources/ViewTypes/Sheet.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ extension iOSViewVersion<SheetType, UIPresentationController> {
7979
public static let v18 = Self(for: .v18, selector: selector)
8080

8181
private static var selector: IntrospectionSelector<UIPresentationController> {
82-
.from(UIViewController.self, selector: \.presentationController)
82+
.from(UIViewController.self, selector: { $0.presentationController })
8383
}
8484
}
8585

@@ -96,7 +96,7 @@ extension iOSViewVersion<SheetType, UISheetPresentationController> {
9696
public static let v18 = Self(for: .v18, selector: selector)
9797

9898
private static var selector: IntrospectionSelector<UISheetPresentationController> {
99-
.from(UIViewController.self, selector: \.sheetPresentationController)
99+
.from(UIViewController.self, selector: { $0.sheetPresentationController })
100100
}
101101
}
102102

@@ -106,7 +106,7 @@ extension visionOSViewVersion<SheetType, UISheetPresentationController> {
106106
public static let v2 = Self(for: .v2, selector: selector)
107107

108108
private static var selector: IntrospectionSelector<UISheetPresentationController> {
109-
.from(UIViewController.self, selector: \.sheetPresentationController)
109+
.from(UIViewController.self, selector: { $0.sheetPresentationController })
110110
}
111111
}
112112
#endif
@@ -120,7 +120,7 @@ extension tvOSViewVersion<SheetType, UIPresentationController> {
120120
public static let v18 = Self(for: .v18, selector: selector)
121121

122122
private static var selector: IntrospectionSelector<UIPresentationController> {
123-
.from(UIViewController.self, selector: \.presentationController)
123+
.from(UIViewController.self, selector: { $0.presentationController })
124124
}
125125
}
126126
#endif

Sources/ViewTypes/Window.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ extension iOSViewVersion<WindowType, UIWindow> {
7070
public static let v18 = Self(for: .v18, selector: selector)
7171

7272
private static var selector: IntrospectionSelector<UIWindow> {
73-
.from(UIView.self, selector: \.window)
73+
.from(UIView.self, selector: { $0.window })
7474
}
7575
}
7676

@@ -83,7 +83,7 @@ extension tvOSViewVersion<WindowType, UIWindow> {
8383
public static let v18 = Self(for: .v18, selector: selector)
8484

8585
private static var selector: IntrospectionSelector<UIWindow> {
86-
.from(UIView.self, selector: \.window)
86+
.from(UIView.self, selector: { $0.window })
8787
}
8888
}
8989

@@ -92,7 +92,7 @@ extension visionOSViewVersion<WindowType, UIWindow> {
9292
public static let v2 = Self(for: .v2, selector: selector)
9393

9494
private static var selector: IntrospectionSelector<UIWindow> {
95-
.from(UIView.self, selector: \.window)
95+
.from(UIView.self, selector: { $0.window })
9696
}
9797
}
9898
#elseif canImport(AppKit)
@@ -105,7 +105,7 @@ extension macOSViewVersion<WindowType, NSWindow> {
105105
public static let v15 = Self(for: .v15, selector: selector)
106106

107107
private static var selector: IntrospectionSelector<NSWindow> {
108-
.from(NSView.self, selector: \.window)
108+
.from(NSView.self, selector: { $0.window })
109109
}
110110
}
111111
#endif

0 commit comments

Comments
 (0)