Skip to content

Commit eac5ec3

Browse files
committed
Enable strict concurrency
1 parent 85d5993 commit eac5ec3

24 files changed

+59
-47
lines changed

Package.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ let package = Package(
138138
"Views/TupleViewChildren.swift.gyb",
139139
"Views/TableRowContent.swift.gyb",
140140
"Scenes/TupleScene.swift.gyb",
141+
],
142+
swiftSettings: [
143+
.enableUpcomingFeature("StrictConcurrency")
141144
]
142145
),
143146
.testTarget(

Sources/HotReloadingMacrosPlugin/HotReloadableAppMacro.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ extension HotReloadableAppMacro: MemberMacro {
104104
105105
if !hotReloadingHasConnectedToServer {
106106
hotReloadingHasConnectedToServer = true
107-
Task {
107+
Task { @MainActor
108108
do {
109109
var client = try await HotReloadingClient()
110110
print("Hot reloading: received new dylib")

Sources/SwiftCrossUI/App.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ public protocol App {
2525

2626
/// Force refresh the entire scene graph. Used by hot reloading. If you need to do
2727
/// this in your own code then something has gone very wrong...
28+
@MainActor
2829
public var _forceRefresh: () -> Void = {}
2930

3031
/// Metadata embedded by Swift Bundler if present. Loaded at app start up.
32+
@MainActor
3133
private var swiftBundlerAppMetadata: AppMetadata?
3234

3335
/// An error encountered when parsing Swift Bundler metadata.
3436
private enum SwiftBundlerMetadataError: LocalizedError {
35-
case jsonNotDictionary(Any)
37+
case jsonNotDictionary(String)
3638
case missingAppIdentifier
3739
case missingAppVersion
3840

@@ -95,7 +97,7 @@ extension App {
9597
// require a lot of boilerplate code to parse with Codable).
9698
let jsonValue = try JSONSerialization.jsonObject(with: jsonData)
9799
guard let json = jsonValue as? [String: Any] else {
98-
throw SwiftBundlerMetadataError.jsonNotDictionary(jsonValue)
100+
throw SwiftBundlerMetadataError.jsonNotDictionary(String(describing: jsonValue))
99101
}
100102
guard let identifier = json["appIdentifier"] as? String else {
101103
throw SwiftBundlerMetadataError.missingAppIdentifier

Sources/SwiftCrossUI/Environment/Actions/AlertAction.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
/// This exists to avoid having to expose internal details of ``Button``, since
55
/// breaking ``Button``'s API would have much more wide-reaching impacts than
66
/// breaking this single-purpose API.
7-
public struct AlertAction {
7+
public struct AlertAction: Sendable {
88
public static let ok = AlertAction(label: "Ok", action: {})
99

1010
public var label: String
11-
public var action: () -> Void
11+
public var action: @MainActor @Sendable () -> Void
1212
}

Sources/SwiftCrossUI/Layout/ViewSize.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/// stored separately to make it extra clear that they don't always form some
66
/// sort of achievable minimum/maximum size. The provided minimum/maximum bounds
77
/// may only be achievable along a single axis at a time.
8-
public struct ViewSize: Equatable {
8+
public struct ViewSize: Equatable, Sendable {
99
/// The view update result for an empty view.
1010
public static let empty = ViewSize(
1111
size: .zero,

Sources/SwiftCrossUI/Scenes/CommandMenu.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
public struct CommandMenu {
1+
public struct CommandMenu: Sendable {
22
var name: String
33
var content: [MenuItem]
44

Sources/SwiftCrossUI/Scenes/Commands.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
public struct Commands {
2-
public static var empty = Commands(menus: [])
1+
public struct Commands: Sendable {
2+
public static let empty = Commands(menus: [])
33

44
var menus: [CommandMenu]
55

Sources/SwiftCrossUI/Values/Axis.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public enum Axis: Sendable {
66
case vertical
77

88
/// A set of axes represented as an efficient bit field.
9-
public struct Set: OptionSet {
9+
public struct Set: OptionSet, Sendable {
1010
/// The horizontal axis.
1111
public static let horizontal = Set(rawValue: 1)
1212
/// The vertical axis.

Sources/SwiftCrossUI/Values/ContentType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// A content type corresponding to a specific file/data format.
2-
public struct ContentType {
2+
public struct ContentType: Sendable {
33
public static let html = ContentType(
44
name: "HTML",
55
mimeTypes: ["text/html"],

Sources/SwiftCrossUI/Values/Edge.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public enum Edge: Int8, CaseIterable, Hashable, Sendable {
1010
case trailing
1111

1212
/// An efficient set of Edges.
13-
public struct Set: OptionSet, Hashable {
13+
public struct Set: OptionSet, Hashable, Sendable {
1414
public let rawValue: Int8
1515

1616
public init(rawValue: Int8) {

0 commit comments

Comments
 (0)