Skip to content

Commit

Permalink
Add explicit @MainActor to Button initializer (#236)
Browse files Browse the repository at this point in the history
* Add explicit `@MainActor` to `Button` initializer

This works around a regression in behavior introduced by Xcode 16 beta
3.

* Scope
  • Loading branch information
stephencelis authored Oct 8, 2024
1 parent 7c3a9eb commit 16a27ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Sources/SwiftNavigation/ButtonState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Action>(_ button: ButtonState<Action>, action: @escaping (Action?) -> Void) {
self.init(
role: button.role.map(ButtonRole.init),
Expand Down
3 changes: 3 additions & 0 deletions Sources/SwiftUINavigation/Alert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Value>(
_ state: Binding<AlertState<Value>?>,
action handler: @escaping (Value?) -> Void = { (_: Never?) in }
Expand Down

0 comments on commit 16a27ab

Please sign in to comment.