Skip to content

Commit

Permalink
Strict concurrency checking
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Mar 27, 2024
1 parent 3edc12d commit 747eec4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.6
// swift-tools-version: 5.8

import PackageDescription

Expand All @@ -20,3 +20,13 @@ let package = Package(
.testTarget(name: "NSUITests", dependencies: ["NSUI"]),
]
)

let swiftSettings: [SwiftSetting] = [
.enableExperimentalFeature("StrictConcurrency"),
]

for target in package.targets {
var settings = target.swiftSettings ?? []
settings.append(contentsOf: swiftSettings)
target.swiftSettings = settings
}
8 changes: 8 additions & 0 deletions Sources/NSUI/ViewRepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ import AppKit
public protocol NSUIViewRepresentable: NSViewRepresentable {
associatedtype NSUIViewType: NSView

@MainActor
func makeNSUIView(context: Context) -> NSUIViewType
@MainActor
func updateNSUIView(_ view: NSUIViewType, context: Context)
}

public extension NSUIViewRepresentable {
@MainActor
func makeNSView(context: Context) -> NSUIViewType {
makeNSUIView(context: context)
}

@MainActor
func updateNSView(_ view: NSUIViewType, context: Context) {
updateNSUIView(view, context: context)
}
Expand All @@ -26,15 +30,19 @@ import UIKit
public protocol NSUIViewRepresentable: UIViewRepresentable {
associatedtype NSUIViewType: UIView

@MainActor
func makeNSUIView(context: Context) -> NSUIViewType
@MainActor
func updateNSUIView(_ view: NSUIViewType, context: Context)
}

public extension NSUIViewRepresentable {
@MainActor
func makeUIView(context: Context) -> NSUIViewType {
makeNSUIView(context: context)
}

@MainActor
func updateUIView(_ view: NSUIViewType, context: Context) {
updateNSUIView(view, context: context)
}
Expand Down
1 change: 1 addition & 0 deletions Tests/NSUITests/ControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ final class MyController: NSUIViewController {
}

final class ControllerTests: XCTestCase {
@MainActor
func testControllerClassDefinition() throws {
let _ = MyController()
}
Expand Down
2 changes: 2 additions & 0 deletions Tests/NSUITests/TextViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import XCTest
@testable import NSUI

final class TextViewTests: XCTestCase {
@MainActor
func testTextViewText() throws {
let textView = NSUITextView()

Expand All @@ -10,6 +11,7 @@ final class TextViewTests: XCTestCase {
XCTAssertEqual(textView.text, "abc")
}

@MainActor
func testEditActions() throws {
let edit = NSUITextStorageEditActions.editedAttributes

Expand Down
1 change: 1 addition & 0 deletions Tests/NSUITests/ViewRepresentableTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import XCTest
@testable import NSUI

@MainActor
struct RepresentedView: NSUIViewRepresentable {
typealias NSUIViewType = NSUIView

Expand Down

0 comments on commit 747eec4

Please sign in to comment.