Skip to content

Commit

Permalink
Swift Language Support: Drop <5.9, Add 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Jun 14, 2024
1 parent 20c0f00 commit bb7c3e5
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 167 deletions.
18 changes: 0 additions & 18 deletions Dependencies.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@
"version" : "1.0.0"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b",
"version" : "1.4.0"
}
},
{
"identity" : "swift-benchmark",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/swift-benchmark",
"state" : {
"revision" : "8163295f6fe82356b0bcf8e1ab991645de17d096",
"version" : "0.1.2"
}
},
{
"identity" : "swift-clocks",
"kind" : "remoteSourceControl",
Expand Down
68 changes: 60 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// swift-tools-version: 5.7.1
// swift-tools-version: 5.9

import CompilerPluginSupport
import PackageDescription

let package = Package(
Expand All @@ -14,16 +15,26 @@ let package = Package(
.library(
name: "Dependencies",
targets: ["Dependencies"]
)
),
.library(
name: "DependenciesMacros",
targets: ["DependenciesMacros"]
),
],
dependencies: [
.package(url: "https://github.com/google/swift-benchmark", from: "0.1.0"),
.package(url: "https://github.com/apple/swift-syntax", "509.0.0"..<"601.0.0"),
.package(url: "https://github.com/pointfreeco/combine-schedulers", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swift-clocks", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.1.0"),
],
targets: [
.target(
name: "DependenciesTestObserver",
dependencies: [
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
]
),
.target(
name: "Dependencies",
dependencies: [
Expand All @@ -36,22 +47,63 @@ let package = Package(
.testTarget(
name: "DependenciesTests",
dependencies: [
"Dependencies"
"Dependencies",
"DependenciesMacros",
]
),
.executableTarget(
name: "swift-dependencies-benchmark",
.target(
name: "DependenciesMacros",
dependencies: [
"Dependencies",
.product(name: "Benchmark", package: "swift-benchmark"),
"DependenciesMacrosPlugin",
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
]
),
.macro(
name: "DependenciesMacrosPlugin",
dependencies: [
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
]
),
]
)

#if !os(macOS) && !os(WASI)
package.products.append(
.library(
name: "DependenciesTestObserver",
type: .dynamic,
targets: ["DependenciesTestObserver"]
)
)
#endif

#if !os(WASI)
package.dependencies.append(
.package(url: "https://github.com/pointfreeco/swift-macro-testing", from: "0.2.0")
)
package.targets.append(contentsOf: [
.testTarget(
name: "DependenciesMacrosPluginTests",
dependencies: [
"DependenciesMacros",
"DependenciesMacrosPlugin",
.product(name: "MacroTesting", package: "swift-macro-testing"),
]
),
])
#endif

#if !os(Windows)
// Add the documentation compiler plugin if possible
package.dependencies.append(
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")
)
#endif

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(contentsOf: [
.enableExperimentalFeature("StrictConcurrency")
])
}
25 changes: 3 additions & 22 deletions [email protected][email protected]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.9
// swift-tools-version: 6.0

import CompilerPluginSupport
import PackageDescription
Expand All @@ -23,7 +23,6 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/apple/swift-syntax", "509.0.0"..<"601.0.0"),
.package(url: "https://github.com/google/swift-benchmark", from: "0.1.0"),
.package(url: "https://github.com/pointfreeco/combine-schedulers", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swift-clocks", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.0.0"),
Expand Down Expand Up @@ -66,14 +65,8 @@ let package = Package(
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
]
),
.executableTarget(
name: "swift-dependencies-benchmark",
dependencies: [
"Dependencies",
.product(name: "Benchmark", package: "swift-benchmark"),
]
),
]
],
swiftLanguageVersions: [.v6]
)

#if !os(macOS) && !os(WASI)
Expand Down Expand Up @@ -108,15 +101,3 @@ let package = Package(
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")
)
#endif

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(contentsOf: [
.enableExperimentalFeature("StrictConcurrency")
])
// target.swiftSettings?.append(
// .unsafeFlags([
// "-enable-library-evolution",
// ])
// )
}
15 changes: 4 additions & 11 deletions Sources/Dependencies/Internal/RuntimeWarnings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func runtimeWarn(
#if canImport(os)
os_log(
.fault,
dso: dso,
dso: dso.wrappedValue,
log: OSLog(subsystem: "com.apple.runtime-issues", category: category),
"%@",
message
Expand Down Expand Up @@ -55,15 +55,8 @@ func runtimeWarn(
// To work around this, we hook into SwiftUI's runtime issue delivery mechanism, instead.
//
// Feedback filed: https://gist.github.com/stephencelis/a8d06383ed6ccde3e5ef5d1b3ad52bbc
#if swift(>=5.10)
@usableFromInline
nonisolated(unsafe) let dso = getSwiftUIDSO()
#else
@usableFromInline
let dso = getSwiftUIDSO()
#endif

private func getSwiftUIDSO() -> UnsafeMutableRawPointer {
@usableFromInline
let dso = UncheckedSendable({
let count = _dyld_image_count()
for i in 0..<count {
if let name = _dyld_get_image_name(i) {
Expand All @@ -76,7 +69,7 @@ func runtimeWarn(
}
}
return UnsafeMutableRawPointer(mutating: #dsohandle)
}
}())
#elseif os(WASI)
#if canImport(JavaScriptCore)
import JavaScriptCore
Expand Down
78 changes: 0 additions & 78 deletions Sources/swift-dependencies-benchmark/WithValue.swift

This file was deleted.

6 changes: 0 additions & 6 deletions Sources/swift-dependencies-benchmark/main.swift

This file was deleted.

24 changes: 0 additions & 24 deletions Tests/DependenciesTests/DependencyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,30 +183,6 @@ final class DependencyTests: XCTestCase {
XCTAssertEqual("cool", greatGrandchild.string)
}

// NB: `@Dependency` should not be used as a `static var` because of the following behavior.
func testStaticDependencyCachesFirstUse() {
struct User {
@Dependency(\.uuid) static var uuid

let id: UUID

init() {
self.id = Self.uuid()
}
}

let user1 = withDependencies {
$0.uuid = .incrementing
} operation: {
User()
}

let user2 = User()

XCTAssertEqual(user1.id, UUID(0))
XCTAssertEqual(user2.id, UUID(1))
}

func testDependencyType() {
struct MyDependency: TestDependencyKey {
static var testValue: Int { 0 }
Expand Down

0 comments on commit bb7c3e5

Please sign in to comment.