From 29ca8d6182fcea313892aafc7fbe8f9ad2f59430 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Mon, 7 Oct 2024 15:54:58 -0700 Subject: [PATCH 1/2] Add explicit `@MainActor` to `Button` initializer This works around a regression in behavior introduced by Xcode 16 beta 3. --- Sources/SwiftNavigation/ButtonState.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/SwiftNavigation/ButtonState.swift b/Sources/SwiftNavigation/ButtonState.swift index 86fec8a1f..451353ee5 100644 --- a/Sources/SwiftNavigation/ButtonState.swift +++ b/Sources/SwiftNavigation/ButtonState.swift @@ -321,6 +321,7 @@ extension ButtonState: Sendable where Action: Sendable {} /// - button: Button state. /// - action: An action closure that is invoked when the button is tapped. @available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) + @MainActor public init(_ button: ButtonState, action: @escaping (Action?) -> Void) { self.init( role: button.role.map(ButtonRole.init), From 2837374ef6024a778d950bb2f1cd6189430c41da Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Mon, 7 Oct 2024 16:15:12 -0700 Subject: [PATCH 2/2] Scope --- Sources/SwiftNavigation/ButtonState.swift | 4 +++- Sources/SwiftUINavigation/Alert.swift | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftNavigation/ButtonState.swift b/Sources/SwiftNavigation/ButtonState.swift index 451353ee5..5722c380a 100644 --- a/Sources/SwiftNavigation/ButtonState.swift +++ b/Sources/SwiftNavigation/ButtonState.swift @@ -321,7 +321,9 @@ extension ButtonState: Sendable where Action: Sendable {} /// - button: Button state. /// - action: An action closure that is invoked when the button is tapped. @available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) - @MainActor + #if compiler(>=6) + @MainActor + #endif public init(_ button: ButtonState, action: @escaping (Action?) -> Void) { self.init( role: button.role.map(ButtonRole.init), diff --git a/Sources/SwiftUINavigation/Alert.swift b/Sources/SwiftUINavigation/Alert.swift index d4f810ae1..138325072 100644 --- a/Sources/SwiftUINavigation/Alert.swift +++ b/Sources/SwiftUINavigation/Alert.swift @@ -149,6 +149,9 @@ /// dismisses the alert, and the action is fed to the `action` closure. /// - handler: A closure that is called with an action from a particular alert button when /// tapped. + #if compiler(>=6) + @MainActor + #endif public func alert( _ state: Binding?>, action handler: @escaping (Value?) -> Void = { (_: Never?) in }