From 8ad666a89cb17c7413b0928050afb9c54aa1d6a4 Mon Sep 17 00:00:00 2001 From: Nick Cipollo Date: Fri, 11 Oct 2024 15:29:21 -0400 Subject: [PATCH] Add support for Swift 6.0 --- .../xcshareddata/WorkspaceSettings.xcsettings | 8 ++ .../xcschemes/WhoopDIKit.xcscheme | 79 +++++++++++++++++++ Package.resolved | 9 ++- Package.swift | 6 +- Sources/WhoopDIKit/ServiceKey.swift | 2 +- Sources/WhoopDIKit/WhoopDI.swift | 4 +- Tests/WhoopDIKitTests/InjectableTests.swift | 7 +- 7 files changed, 104 insertions(+), 11 deletions(-) create mode 100644 .swiftpm/xcode/package.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/WhoopDIKit.xcscheme diff --git a/.swiftpm/xcode/package.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/.swiftpm/xcode/package.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..54782e3 --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded + + + diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/WhoopDIKit.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/WhoopDIKit.xcscheme new file mode 100644 index 0000000..c9d3213 --- /dev/null +++ b/.swiftpm/xcode/xcshareddata/xcschemes/WhoopDIKit.xcscheme @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Package.resolved b/Package.resolved index fa0a833..8fd79da 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,14 +1,15 @@ { + "originHash" : "3262a5846ea4516117d0058e3c3efc147f6e7e7eafb82b0dd6de03a2d3e001d4", "pins" : [ { "identity" : "swift-syntax", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", + "location" : "https://github.com/swiftlang/swift-syntax.git", "state" : { - "revision" : "64889f0c732f210a935a0ad7cda38f77f876262d", - "version" : "509.1.1" + "revision" : "0687f71944021d616d34d922343dcef086855920", + "version" : "600.0.1" } } ], - "version" : 2 + "version" : 3 } diff --git a/Package.swift b/Package.swift index 1863d5a..c5d8e1b 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.9 +// swift-tools-version:6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import CompilerPluginSupport @@ -14,10 +14,10 @@ let package = Package( products: [ .library( name: "WhoopDIKit", - targets: ["WhoopDIKit", "WhoopDIKitMacros"]), + targets: ["WhoopDIKit",]), ], dependencies: [ - .package(url: "https://github.com/apple/swift-syntax.git", from: "509.0.0") + .package(url: "https://github.com/swiftlang/swift-syntax.git", from: "600.0.0-latest") ], targets: [ .target( diff --git a/Sources/WhoopDIKit/ServiceKey.swift b/Sources/WhoopDIKit/ServiceKey.swift index 657c19e..07ed707 100644 --- a/Sources/WhoopDIKit/ServiceKey.swift +++ b/Sources/WhoopDIKit/ServiceKey.swift @@ -1,6 +1,6 @@ /// Hashable wrapper for a metatype value. /// See https://stackoverflow.com/questions/42459484/make-a-swift-dictionary-where-the-key-is-type -public struct ServiceKey { +public struct ServiceKey: Sendable { public let type: Any.Type public let name: String? diff --git a/Sources/WhoopDIKit/WhoopDI.swift b/Sources/WhoopDIKit/WhoopDI.swift index c2026d3..e08279a 100644 --- a/Sources/WhoopDIKit/WhoopDI.swift +++ b/Sources/WhoopDIKit/WhoopDI.swift @@ -1,7 +1,7 @@ import Foundation public final class WhoopDI: DependencyRegister { - private static let serviceDict = ServiceDictionary() - private static var localServiceDict: ServiceDictionary? = nil + nonisolated(unsafe) private static let serviceDict = ServiceDictionary() + nonisolated(unsafe) private static var localServiceDict: ServiceDictionary? = nil /// Registers a list of modules with the DI system. /// Typically you will create a `DependencyModule` for your feature, then add it to the module list provided to this method. diff --git a/Tests/WhoopDIKitTests/InjectableTests.swift b/Tests/WhoopDIKitTests/InjectableTests.swift index 4670850..a21676f 100644 --- a/Tests/WhoopDIKitTests/InjectableTests.swift +++ b/Tests/WhoopDIKitTests/InjectableTests.swift @@ -1,8 +1,12 @@ import Foundation -@testable import WhoopDIKitMacros import SwiftSyntaxMacrosTestSupport import XCTest +// Macro implementations build for the host, so the corresponding module is not available when cross-compiling. +// Cross-compiled tests may still make use of the macro itself in end-to-end tests. +#if canImport(WhoopDIKitMacros) +@testable import WhoopDIKitMacros + final class InjectableTests: XCTestCase { func testBasicInject() { assertMacroExpansion( @@ -132,3 +136,4 @@ final class InjectableTests: XCTestCase { macros: ["Injectable": InjectableMacro.self]) } } +#endif