Skip to content

Commit 38f57fc

Browse files
committed
Mac-specific fixes
1 parent 0a0f660 commit 38f57fc

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

Sources/SwiftCrossUI/Backend/AppBackend.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import Foundation
4141
/// (since the `update` method is always called between calling `create`
4242
/// and actually displaying the widget anyway).
4343
@MainActor
44-
public protocol AppBackend {
44+
public protocol AppBackend: Sendable {
4545
associatedtype Window
4646
associatedtype Widget
4747
associatedtype Menu

Sources/SwiftCrossUI/Environment/Actions/OpenURLAction.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import Foundation
22

33
/// Opens a URL with the default application. May present an application picker
44
/// if multiple applications are registered for the given URL protocol.
5+
@MainActor
56
public struct OpenURLAction {
6-
let action: @MainActor (URL) -> Void
7+
let action: (URL) -> Void
78

89
init<Backend: AppBackend>(backend: Backend) {
910
action = { url in
@@ -15,7 +16,6 @@ public struct OpenURLAction {
1516
}
1617
}
1718

18-
@MainActor
1919
public func callAsFunction(_ url: URL) {
2020
action(url)
2121
}

Sources/SwiftCrossUI/Environment/EnvironmentValues.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public struct EnvironmentValues {
130130
/// Opens a URL with the default application. May present an application
131131
/// picker if multiple applications are registered for the given URL
132132
/// protocol.
133+
@MainActor
133134
public var openURL: OpenURLAction {
134135
return OpenURLAction(
135136
backend: backend

Sources/UIKitBackend/KeyboardToolbar.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ public protocol ToolbarItem {
1414
associatedtype ItemType: UIBarButtonItem
1515

1616
/// Convert the item to an instance of `ItemType`.
17+
@MainActor
1718
func createBarButtonItem() -> ItemType
1819

1920
/// Update the item with new information (e.g. updated bindings). May be a no-op.
21+
@MainActor
2022
func updateBarButtonItem(_ item: inout ItemType)
2123
}
2224

@@ -61,9 +63,9 @@ public enum ToolbarBuilder {
6163
@available(tvOS, unavailable)
6264
extension Button: ToolbarItem {
6365
public final class ItemType: UIBarButtonItem {
64-
var callback: () -> Void
66+
var callback: @MainActor @Sendable () -> Void
6567

66-
init(title: String, callback: @escaping () -> Void) {
68+
init(title: String, callback: @escaping @MainActor @Sendable () -> Void) {
6769
self.callback = callback
6870
super.init()
6971

Tests/SwiftCrossUITests/SwiftCrossUITests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ final class SwiftCrossUITests: XCTestCase {
6565
}
6666

6767
#if canImport(AppKitBackend)
68-
func testBasicLayout() throws {
68+
@MainActor
69+
func testBasicLayout() async throws {
6970
let backend = AppKitBackend()
7071
let window = backend.createWindow(withDefaultSize: SIMD2(200, 200))
7172

@@ -104,6 +105,7 @@ final class SwiftCrossUITests: XCTestCase {
104105
)
105106
}
106107

108+
@MainActor
107109
static func snapshotView(_ view: NSView) throws -> Data {
108110
view.wantsLayer = true
109111
view.layer?.backgroundColor = CGColor.white

0 commit comments

Comments
 (0)