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

+7-14
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

+12-7
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

+8-2
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

+7-1
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

+2-5
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

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
{
2+
"originHash" : "c92107a159713b44e293a2fe944a02f419f98dc401c81653bfee56d07c8a2b70",
23
"pins" : [
34
{
45
"identity" : "opengraph",
56
"kind" : "remoteSourceControl",
67
"location" : "https://github.com/OpenSwiftUIProject/OpenGraph",
78
"state" : {
89
"branch" : "main",
9-
"revision" : "6bdaabae4e0e23868f657c24fd09580f8915519c"
10+
"revision" : "dd6cacbdcf2af1d8f7ce2b0e7194a920935326de"
1011
}
1112
},
1213
{
1314
"identity" : "swift-syntax",
1415
"kind" : "remoteSourceControl",
1516
"location" : "https://github.com/apple/swift-syntax.git",
1617
"state" : {
17-
"revision" : "64889f0c732f210a935a0ad7cda38f77f876262d",
18-
"version" : "509.1.1"
18+
"revision" : "fa8f95c2d536d6620cc2f504ebe8a6167c9fc2dd",
19+
"version" : "510.0.1"
1920
}
2021
},
2122
{
2223
"identity" : "swift-testing",
2324
"kind" : "remoteSourceControl",
2425
"location" : "https://github.com/apple/swift-testing",
2526
"state" : {
26-
"revision" : "126e4be6857bda76aab3f45282bc6cfff5ac876a",
27-
"version" : "0.3.0"
27+
"revision" : "8097dd8bcf7f2ed85f8aa8883635ce413012f53b",
28+
"version" : "0.6.0"
2829
}
2930
}
3031
],
31-
"version" : 2
32+
"version" : 3
3233
}

Package.swift

+4-3
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

+2-2
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)