From 831c079e8460e1b1ce2cd00b50723be17269bda8 Mon Sep 17 00:00:00 2001 From: Kyle Date: Tue, 2 Apr 2024 22:24:58 +0800 Subject: [PATCH] Bump minimum support version to Swift 5.10 (#57) * Bump minimum support version to Swift 5.10 * Fix warning about ObservedObject --- .github/workflows/compatibility_tests.yml | 21 +++++++------------ .github/workflows/ios.yml | 19 ++++++++++------- .github/workflows/macos.yml | 10 +++++++-- .github/workflows/ubuntu.yml | 8 ++++++- .github/workflows/wasm.yml | 7 ++----- Package.resolved | 13 ++++++------ Package.swift | 7 ++++--- .../Data/Model/State/ObservedObject.swift | 4 ++-- 8 files changed, 49 insertions(+), 40 deletions(-) diff --git a/.github/workflows/compatibility_tests.yml b/.github/workflows/compatibility_tests.yml index 71d74cb..191d27b 100644 --- a/.github/workflows/compatibility_tests.yml +++ b/.github/workflows/compatibility_tests.yml @@ -13,9 +13,14 @@ jobs: fail-fast: false matrix: include: - - os: macos-13 - xcode-version: "15.1" # Swift 5.9.2 + - os: macos-14 + xcode-version: "15.3" # Swift 5.10 runs-on: ${{ matrix.os }} + env: + OPENSWIFTUI_WERROR: 1 + OPENSWIFTUI_SWIFT_TESTING: 1 + OPENGRAPH_ATTRIBUTEGRAPH: 1 + OPENSWIFTUI_SWIFT_LOG: 0 steps: - uses: actions/checkout@v4 - name: Setup Xcode @@ -36,15 +41,3 @@ jobs: --build-path .build-compatibility-test-debug env: OPENSWIFTUI_COMPATIBILITY_TEST: 1 - # - name: Run compatibility tests on OpenSwiftUI + iOS - # run: | - # swift test \ - # --build-path .build-compatibility-test-debug - # env: - # OPENSWIFTUI_COMPATIBILITY_TEST: 0 - # - name: Run compatibility tests on SwiftUI + iOS - # run: | - # swift test \ - # --build-path .build-compatibility-test-debug - # env: - # OPENSWIFTUI_COMPATIBILITY_TEST: 1 \ No newline at end of file diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index eaba4b0..5b4939c 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -13,9 +13,15 @@ jobs: fail-fast: false matrix: include: - - os: macos-13 - xcode-version: "15.2" # Swift 5.9.2 + - os: macos-14 + xcode-version: "15.3" # Swift 5.10 runs-on: ${{ matrix.os }} + env: + OPENSWIFTUI_WERROR: 1 + OPENSWIFTUI_SWIFT_TESTING: 1 + OPENGRAPH_ATTRIBUTEGRAPH: 1 + OPENSWIFTUI_COMPATIBILITY_TEST: 0 + OPENSWIFTUI_SWIFT_LOG: 0 steps: - uses: actions/checkout@v4 - name: Setup Xcode @@ -29,15 +35,14 @@ jobs: xcodebuild build \ -scheme OpenSwiftUI \ -configuration Debug \ - -skipMacroValidation -skipPackagePluginValidation \ -destination "platform=iOS-Simulator" \ - # OpenSwiftUI-Package is not listed currently - # OTHER_SWIFT_FLAGS="-warnings-as-errors" \ AccessLevelOnImport will cause build warning via xcodebuild + -skipMacroValidation \ + -skipPackagePluginValidation - name: Build and run tests in debug mode run: | xcodebuild test \ -scheme OpenSwiftUI \ -configuration Debug \ - -skipMacroValidation -skipPackagePluginValidation \ -destination "platform=iOS-Simulator" \ - # OTHER_SWIFT_FLAGS="-warnings-as-errors" \ No newline at end of file + -skipMacroValidation \ + -skipPackagePluginValidation diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 4397863..097935e 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -13,9 +13,15 @@ jobs: fail-fast: false matrix: include: - - os: macos-13 - xcode-version: "15.2" # Swift 5.9.2 + - os: macos-14 + xcode-version: "15.3" # Swift 5.10 runs-on: ${{ matrix.os }} + env: + OPENSWIFTUI_WERROR: 1 + OPENSWIFTUI_SWIFT_TESTING: 1 + OPENGRAPH_ATTRIBUTEGRAPH: 1 + OPENSWIFTUI_COMPATIBILITY_TEST: 0 + OPENSWIFTUI_SWIFT_LOG: 0 steps: - uses: actions/checkout@v4 - name: Setup Xcode diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index f35b8e5..298d774 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -12,8 +12,14 @@ jobs: strategy: fail-fast: false matrix: - swift_version: ["5.9.2"] + swift_version: ["5.10"] runs-on: ubuntu-22.04 + env: + OPENSWIFTUI_WERROR: 1 + OPENSWIFTUI_SWIFT_TESTING: 1 + OPENGRAPH_ATTRIBUTEGRAPH: 0 + OPENSWIFTUI_COMPATIBILITY_TEST: 0 + OPENSWIFTUI_SWIFT_LOG: 1 container: swift:${{ matrix.swift_version }}-jammy steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index a899fc2..50c0e55 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -12,17 +12,14 @@ jobs: strategy: fail-fast: false matrix: - swift_version: ["wasm-5.9.1-RELEASE"] + swift_version: ["5.10-SNAPSHOT-2024-03-30-a"] # "5.10-RELEASE" is not release for WASM, tracked via https://github.com/swiftwasm/swift/issues/5570 os: [ubuntu-22.04] - include: - - swift_version: "wasm-5.9.1-RELEASE" - extra_params: "-Xswiftc -Xfrontend -Xswiftc -disable-round-trip-debug-types" # https://github.com/swiftwasm/swift/issues/5563#issuecomment-1913533592 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: swiftwasm/setup-swiftwasm@v1 with: - swift-version: ${{ matrix.swift_version }} + swift-version: wasm-${{ matrix.swift_version }} - name: build run: | swift build --triple wasm32-unknown-wasi ${{ matrix.extra_params }} diff --git a/Package.resolved b/Package.resolved index dcdaf68..b538ffd 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,4 +1,5 @@ { + "originHash" : "c92107a159713b44e293a2fe944a02f419f98dc401c81653bfee56d07c8a2b70", "pins" : [ { "identity" : "opengraph", @@ -6,7 +7,7 @@ "location" : "https://github.com/OpenSwiftUIProject/OpenGraph", "state" : { "branch" : "main", - "revision" : "6bdaabae4e0e23868f657c24fd09580f8915519c" + "revision" : "dd6cacbdcf2af1d8f7ce2b0e7194a920935326de" } }, { @@ -14,8 +15,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-syntax.git", "state" : { - "revision" : "64889f0c732f210a935a0ad7cda38f77f876262d", - "version" : "509.1.1" + "revision" : "fa8f95c2d536d6620cc2f504ebe8a6167c9fc2dd", + "version" : "510.0.1" } }, { @@ -23,10 +24,10 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing", "state" : { - "revision" : "126e4be6857bda76aab3f45282bc6cfff5ac876a", - "version" : "0.3.0" + "revision" : "8097dd8bcf7f2ed85f8aa8883635ce413012f53b", + "version" : "0.6.0" } } ], - "version" : 2 + "version" : 3 } diff --git a/Package.swift b/Package.swift index 0dbed1c..16f3dfc 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.9 +// swift-tools-version: 5.10 // The swift-tools-version declares the minimum version of Swift required to build this package. import Foundation @@ -18,6 +18,7 @@ func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool { } let isXcodeEnv = Context.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode" +let development = envEnable("OPENSWIFTUI_DEVELOPMENT", default: false) // Xcode use clang as linker which supports "-iframework" while SwiftPM use swiftc as linker which supports "-Fsystem" let systemFrameworkSearchFlag = isXcodeEnv ? "-iframework" : "-Fsystem" @@ -27,7 +28,7 @@ var sharedSwiftSettings: [SwiftSetting] = [ .define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS"), ] -let warningsAsErrorsCondition = envEnable("OPENSWIFTUI_WERROR", default: isXcodeEnv) +let warningsAsErrorsCondition = envEnable("OPENSWIFTUI_WERROR", default: isXcodeEnv && development) if warningsAsErrorsCondition { sharedSwiftSettings.append(.unsafeFlags(["-warnings-as-errors"])) } @@ -167,7 +168,7 @@ let swiftTestingCondition = envEnable("OPENSWIFTUI_SWIFT_TESTING", default: true if swiftTestingCondition { package.dependencies.append( // Fix it to be 0.3.0 before we bump to Swift 5.10 - .package(url: "https://github.com/apple/swift-testing", exact: "0.3.0") + .package(url: "https://github.com/apple/swift-testing", exact: "0.6.0") ) openSwiftUITestTarget.dependencies.append( .product(name: "Testing", package: "swift-testing") diff --git a/Sources/OpenSwiftUI/Data/Model/State/ObservedObject.swift b/Sources/OpenSwiftUI/Data/Model/State/ObservedObject.swift index 4ec665f..7b41e75 100644 --- a/Sources/OpenSwiftUI/Data/Model/State/ObservedObject.swift +++ b/Sources/OpenSwiftUI/Data/Model/State/ObservedObject.swift @@ -163,7 +163,7 @@ public struct ObservedObject where ObjectType: ObservableObject { /// When you change a wrapped value, you can access the new value /// immediately. However, OpenSwiftUI updates views that display the value /// asynchronously, so the interface might not update immediately. - @MainActor + @MainActor(unsafe) public var wrappedValue: ObjectType /// A projection of the observed object that creates bindings to its @@ -183,7 +183,7 @@ public struct ObservedObject where ObjectType: ObservableObject { /// } /// } /// - @MainActor + @MainActor(unsafe) public var projectedValue: ObservedObject.Wrapper { .init(root: wrappedValue) }