From 16a27ab7ae0abfefbbcba73581b3e2380b47a579 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Tue, 8 Oct 2024 09:48:09 -0700 Subject: [PATCH] Add explicit `@MainActor` to `Button` initializer (#236) * Add explicit `@MainActor` to `Button` initializer This works around a regression in behavior introduced by Xcode 16 beta 3. * Scope --- Sources/SwiftNavigation/ButtonState.swift | 3 +++ Sources/SwiftUINavigation/Alert.swift | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Sources/SwiftNavigation/ButtonState.swift b/Sources/SwiftNavigation/ButtonState.swift index 86fec8a1f..5722c380a 100644 --- a/Sources/SwiftNavigation/ButtonState.swift +++ b/Sources/SwiftNavigation/ButtonState.swift @@ -321,6 +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, *) + #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 }