From 00bc30ca03f98881329fab7f1bebef8eba472596 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Wed, 12 Jun 2024 14:42:19 -0700 Subject: [PATCH] Fix some Swift 6 warnings (#224) * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip --- .github/workflows/ci.yml | 29 +++++++------------ .../Dependencies/Internal/Deprecations.swift | 4 +-- .../Internal/RuntimeWarnings.swift | 17 ++++++++--- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14cb70c1..c4bbdc01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,11 +16,11 @@ concurrency: jobs: macos: name: macOS - runs-on: macos-13 + runs-on: macos-14 strategy: matrix: config: ['debug', 'release'] - xcode: ['14.3.1', '15.0.1'] + xcode: ['14.3.1', '15.4.0'] steps: - uses: actions/checkout@v4 - name: Select Xcode ${{ matrix.xcode }} @@ -45,12 +45,19 @@ jobs: # run: make test-integration ubuntu: - name: Linux + strategy: + matrix: + swift: + - '5.10' + name: Ubuntu (Swift ${{ matrix.swift }}) runs-on: ubuntu-latest + container: swift:${{ matrix.swift }} steps: - uses: actions/checkout@v4 - name: Run tests - run: make test-swift + run: swift test --parallel + - name: Run tests (release) + run: swift test -c release --parallel # wasm: # name: Wasm @@ -75,17 +82,3 @@ jobs: # run: swift test # - name: Run tests (release) # run: swift test -c release - - static-stdlib: - strategy: - matrix: - image: ['swift:5.7-focal', 'swift:5.8-focal'] - runs-on: ubuntu-latest - container: - image: ${{ matrix.image }} - steps: - - uses: actions/checkout@v4 - - name: Build for static-stdlib (debug) - run: swift build -c debug --static-swift-stdlib - - name: Build for static-stdlib (release) - run: swift build -c release --static-swift-stdlib diff --git a/Sources/Dependencies/Internal/Deprecations.swift b/Sources/Dependencies/Internal/Deprecations.swift index 78176d59..32756e65 100644 --- a/Sources/Dependencies/Internal/Deprecations.swift +++ b/Sources/Dependencies/Internal/Deprecations.swift @@ -30,9 +30,9 @@ extension ActorIsolated { deprecated, message: "Use the non-async version of 'withValue'." ) - public func withValue( + public func withValue( _ operation: @Sendable (inout Value) async throws -> T - ) async rethrows -> T { + ) async rethrows -> T where Value: Sendable { var value = self.value defer { self.value = value } return try await operation(&value) diff --git a/Sources/Dependencies/Internal/RuntimeWarnings.swift b/Sources/Dependencies/Internal/RuntimeWarnings.swift index 6743832b..32b6eac1 100644 --- a/Sources/Dependencies/Internal/RuntimeWarnings.swift +++ b/Sources/Dependencies/Internal/RuntimeWarnings.swift @@ -43,7 +43,9 @@ func runtimeWarn( #endif } -#if DEBUG +// NB: We can change this to `#if DEBUG` when we drop support for Swift <5.9 +#if RELEASE +#else #if canImport(os) import Foundation import os @@ -53,8 +55,15 @@ func runtimeWarn( // To work around this, we hook into SwiftUI's runtime issue delivery mechanism, instead. // // Feedback filed: https://gist.github.com/stephencelis/a8d06383ed6ccde3e5ef5d1b3ad52bbc - @usableFromInline - let dso = { () -> UnsafeMutableRawPointer in + #if swift(>=5.10) + @usableFromInline + nonisolated(unsafe) let dso = getSwiftUIDSO() + #else + @usableFromInline + let dso = getSwiftUIDSO() + #endif + + private func getSwiftUIDSO() -> UnsafeMutableRawPointer { let count = _dyld_image_count() for i in 0..