Skip to content

Commit 831c079

Browse files
authored
Bump minimum support version to Swift 5.10 (#57)
* Bump minimum support version to Swift 5.10 * Fix warning about ObservedObject
1 parent da9a5ef commit 831c079

File tree

8 files changed

+49
-40
lines changed

8 files changed

+49
-40
lines changed

.github/workflows/compatibility_tests.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
include:
16-
- os: macos-13
17-
xcode-version: "15.1" # Swift 5.9.2
16+
- os: macos-14
17+
xcode-version: "15.3" # Swift 5.10
1818
runs-on: ${{ matrix.os }}
19+
env:
20+
OPENSWIFTUI_WERROR: 1
21+
OPENSWIFTUI_SWIFT_TESTING: 1
22+
OPENGRAPH_ATTRIBUTEGRAPH: 1
23+
OPENSWIFTUI_SWIFT_LOG: 0
1924
steps:
2025
- uses: actions/checkout@v4
2126
- name: Setup Xcode
@@ -36,15 +41,3 @@ jobs:
3641
--build-path .build-compatibility-test-debug
3742
env:
3843
OPENSWIFTUI_COMPATIBILITY_TEST: 1
39-
# - name: Run compatibility tests on OpenSwiftUI + iOS
40-
# run: |
41-
# swift test \
42-
# --build-path .build-compatibility-test-debug
43-
# env:
44-
# OPENSWIFTUI_COMPATIBILITY_TEST: 0
45-
# - name: Run compatibility tests on SwiftUI + iOS
46-
# run: |
47-
# swift test \
48-
# --build-path .build-compatibility-test-debug
49-
# env:
50-
# OPENSWIFTUI_COMPATIBILITY_TEST: 1

.github/workflows/ios.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
include:
16-
- os: macos-13
17-
xcode-version: "15.2" # Swift 5.9.2
16+
- os: macos-14
17+
xcode-version: "15.3" # Swift 5.10
1818
runs-on: ${{ matrix.os }}
19+
env:
20+
OPENSWIFTUI_WERROR: 1
21+
OPENSWIFTUI_SWIFT_TESTING: 1
22+
OPENGRAPH_ATTRIBUTEGRAPH: 1
23+
OPENSWIFTUI_COMPATIBILITY_TEST: 0
24+
OPENSWIFTUI_SWIFT_LOG: 0
1925
steps:
2026
- uses: actions/checkout@v4
2127
- name: Setup Xcode
@@ -29,15 +35,14 @@ jobs:
2935
xcodebuild build \
3036
-scheme OpenSwiftUI \
3137
-configuration Debug \
32-
-skipMacroValidation -skipPackagePluginValidation \
3338
-destination "platform=iOS-Simulator" \
34-
# OpenSwiftUI-Package is not listed currently
35-
# OTHER_SWIFT_FLAGS="-warnings-as-errors" \ AccessLevelOnImport will cause build warning via xcodebuild
39+
-skipMacroValidation \
40+
-skipPackagePluginValidation
3641
- name: Build and run tests in debug mode
3742
run: |
3843
xcodebuild test \
3944
-scheme OpenSwiftUI \
4045
-configuration Debug \
41-
-skipMacroValidation -skipPackagePluginValidation \
4246
-destination "platform=iOS-Simulator" \
43-
# OTHER_SWIFT_FLAGS="-warnings-as-errors"
47+
-skipMacroValidation \
48+
-skipPackagePluginValidation

.github/workflows/macos.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
include:
16-
- os: macos-13
17-
xcode-version: "15.2" # Swift 5.9.2
16+
- os: macos-14
17+
xcode-version: "15.3" # Swift 5.10
1818
runs-on: ${{ matrix.os }}
19+
env:
20+
OPENSWIFTUI_WERROR: 1
21+
OPENSWIFTUI_SWIFT_TESTING: 1
22+
OPENGRAPH_ATTRIBUTEGRAPH: 1
23+
OPENSWIFTUI_COMPATIBILITY_TEST: 0
24+
OPENSWIFTUI_SWIFT_LOG: 0
1925
steps:
2026
- uses: actions/checkout@v4
2127
- name: Setup Xcode

.github/workflows/ubuntu.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
swift_version: ["5.9.2"]
15+
swift_version: ["5.10"]
1616
runs-on: ubuntu-22.04
17+
env:
18+
OPENSWIFTUI_WERROR: 1
19+
OPENSWIFTUI_SWIFT_TESTING: 1
20+
OPENGRAPH_ATTRIBUTEGRAPH: 0
21+
OPENSWIFTUI_COMPATIBILITY_TEST: 0
22+
OPENSWIFTUI_SWIFT_LOG: 1
1723
container: swift:${{ matrix.swift_version }}-jammy
1824
steps:
1925
- uses: actions/checkout@v4

.github/workflows/wasm.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,14 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
swift_version: ["wasm-5.9.1-RELEASE"]
15+
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
1616
os: [ubuntu-22.04]
17-
include:
18-
- swift_version: "wasm-5.9.1-RELEASE"
19-
extra_params: "-Xswiftc -Xfrontend -Xswiftc -disable-round-trip-debug-types" # https://github.com/swiftwasm/swift/issues/5563#issuecomment-1913533592
2017
runs-on: ${{ matrix.os }}
2118
steps:
2219
- uses: actions/checkout@v4
2320
- uses: swiftwasm/setup-swiftwasm@v1
2421
with:
25-
swift-version: ${{ matrix.swift_version }}
22+
swift-version: wasm-${{ matrix.swift_version }}
2623
- name: build
2724
run: |
2825
swift build --triple wasm32-unknown-wasi ${{ matrix.extra_params }}

Package.resolved

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.9
1+
// swift-tools-version: 5.10
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import Foundation
@@ -18,6 +18,7 @@ func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool {
1818
}
1919

2020
let isXcodeEnv = Context.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode"
21+
let development = envEnable("OPENSWIFTUI_DEVELOPMENT", default: false)
2122

2223
// Xcode use clang as linker which supports "-iframework" while SwiftPM use swiftc as linker which supports "-Fsystem"
2324
let systemFrameworkSearchFlag = isXcodeEnv ? "-iframework" : "-Fsystem"
@@ -27,7 +28,7 @@ var sharedSwiftSettings: [SwiftSetting] = [
2728
.define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS"),
2829
]
2930

30-
let warningsAsErrorsCondition = envEnable("OPENSWIFTUI_WERROR", default: isXcodeEnv)
31+
let warningsAsErrorsCondition = envEnable("OPENSWIFTUI_WERROR", default: isXcodeEnv && development)
3132
if warningsAsErrorsCondition {
3233
sharedSwiftSettings.append(.unsafeFlags(["-warnings-as-errors"]))
3334
}
@@ -167,7 +168,7 @@ let swiftTestingCondition = envEnable("OPENSWIFTUI_SWIFT_TESTING", default: true
167168
if swiftTestingCondition {
168169
package.dependencies.append(
169170
// Fix it to be 0.3.0 before we bump to Swift 5.10
170-
.package(url: "https://github.com/apple/swift-testing", exact: "0.3.0")
171+
.package(url: "https://github.com/apple/swift-testing", exact: "0.6.0")
171172
)
172173
openSwiftUITestTarget.dependencies.append(
173174
.product(name: "Testing", package: "swift-testing")

Sources/OpenSwiftUI/Data/Model/State/ObservedObject.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public struct ObservedObject<ObjectType> where ObjectType: ObservableObject {
163163
/// When you change a wrapped value, you can access the new value
164164
/// immediately. However, OpenSwiftUI updates views that display the value
165165
/// asynchronously, so the interface might not update immediately.
166-
@MainActor
166+
@MainActor(unsafe)
167167
public var wrappedValue: ObjectType
168168

169169
/// A projection of the observed object that creates bindings to its
@@ -183,7 +183,7 @@ public struct ObservedObject<ObjectType> where ObjectType: ObservableObject {
183183
/// }
184184
/// }
185185
///
186-
@MainActor
186+
@MainActor(unsafe)
187187
public var projectedValue: ObservedObject<ObjectType>.Wrapper {
188188
.init(root: wrappedValue)
189189
}

0 commit comments

Comments
 (0)