Skip to content

Ensure swiftly passes complete concurrency checks #124

Closed
@cmcgee1024

Description

@cmcgee1024

Now that Swiftly is switching to 5.10 there is the experimental strict concurrency check feature that will help us to prepare for Swift 6's concurrency. You can add the checks like this in the Package.swift:

diff --git a/Package.swift b/Package.swift
index 0f15e50..725e033 100644
--- a/Package.swift
+++ b/Package.swift
@@ -28,14 +28,16 @@ let package = Package(
                 .target(name: "LinuxPlatform", condition: .when(platforms: [.linux])),
                 .target(name: "MacOSPlatform", condition: .when(platforms: [.macOS])),
                 .product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
-            ]
+            ],
+            swiftSettings: [.enableExperimentalFeature("StrictConcurrency=complete")]
         ),
         .target(
             name: "SwiftlyCore",
             dependencies: [
                 .product(name: "AsyncHTTPClient", package: "async-http-client"),
                 .product(name: "NIOFoundationCompat", package: "swift-nio"),
-            ]
+            ],
+            swiftSettings: [.enableExperimentalFeature("StrictConcurrency=complete")]
         ),
         .target(
             name: "LinuxPlatform",
@@ -43,6 +45,7 @@ let package = Package(
                 "SwiftlyCore",
                 "CLibArchive",
             ],
+            swiftSettings: [.enableExperimentalFeature("StrictConcurrency=complete")],
             linkerSettings: [
                 .linkedLibrary("z"),
             ]
@@ -51,7 +54,8 @@ let package = Package(
             name: "MacOSPlatform",
             dependencies: [
                 "SwiftlyCore",
-            ]
+            ],
+            swiftSettings: [.enableExperimentalFeature("StrictConcurrency=complete")]
         ),

When trying this out with the Swiftly code there were a number of warnings that will become errors in Swift 6. These should be fixed in preparation for the update. Here are some examples:

/Users/cmcgee/git/swiftly-public/Sources/SwiftlyCore/SwiftlyVersion.swift:7:16: warning: static property 'regex' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor; this is an error in Swift 6
    static let regex: Regex<(Substring, Substring, Substring, Substring, Substring?)> =
               ^
/Users/cmcgee/git/swiftly-public/Sources/SwiftlyCore/SwiftlyCore.swift:3:12: warning: let 'version' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor; this is an error in Swift 6
public let version = SwiftlyVersion(major: 0, minor: 3, patch: 0)
           ^
/Users/cmcgee/git/swiftly-public/Sources/SwiftlyCore/SwiftlyCore.swift:7:12: warning: var 'mockedHomeDir' is not concurrency-safe because it is non-isolated global shared mutable state; this is an error in Swift 6
public var mockedHomeDir: URL?
           ^
/Users/cmcgee/git/swiftly-public/Sources/SwiftlyCore/SwiftlyCore.swift:7:12: note: isolate 'mockedHomeDir' to a global actor, or convert it to a 'let' constant and conform it to 'Sendable'
public var mockedHomeDir: URL?
           ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions