Skip to content

Commit bb53a7e

Browse files
stephencelisp4checo
authored andcommitted
Require Swift 5.6 (#1491)
* Restore Swift 5.5 compatibility As pointed out in #1489, we somehow lost compatibility with Swift 5.5 (Xcode 13.2). While we hope to drop support when we hit 1.0, let's try to keep compatiblity in the meantime. * Update DependencyValues.swift * Update Sources/Dependencies/DependencyValues.swift Co-authored-by: Brandon Williams <[email protected]> * Require Swift 5.6 * Update ci.yml Co-authored-by: Brandon Williams <[email protected]> (cherry picked from commit e11ca0eddc9a2553d9a422955e9d21af049cef69) # Conflicts: # .github/workflows/ci.yml # Package.swift
1 parent ee043fe commit bb53a7e

File tree

10 files changed

+228
-250
lines changed

10 files changed

+228
-250
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- '14.1'
2424
config: ['debug', 'release']
2525
steps:
26-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v3
2727
- name: Select Xcode ${{ matrix.xcode }}
2828
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
2929
- name: Run ${{ matrix.config }} tests
@@ -36,7 +36,7 @@ jobs:
3636
xcode:
3737
- '14.1'
3838
steps:
39-
- uses: actions/checkout@v2
39+
- uses: actions/checkout@v3
4040
- name: Select Xcode ${{ matrix.xcode }}
4141
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
4242
- name: Build for library evolution
@@ -49,7 +49,7 @@ jobs:
4949
xcode:
5050
- '14.1'
5151
steps:
52-
- uses: actions/checkout@v2
52+
- uses: actions/checkout@v3
5353
- name: Select Xcode ${{ matrix.xcode }}
5454
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
5555
- name: Run benchmark
@@ -62,7 +62,7 @@ jobs:
6262
xcode:
6363
- '14.1'
6464
steps:
65-
- uses: actions/checkout@v2
65+
- uses: actions/checkout@v3
6666
- name: Select Xcode ${{ matrix.xcode }}
6767
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
6868
- name: Run tests

Examples/CaseStudies/tvOSCaseStudies/FocusView.swift

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,58 +32,56 @@ struct Focus: ReducerProtocol {
3232
}
3333
}
3434

35-
#if swift(>=5.3)
36-
@available(tvOS 14.0, *)
37-
struct FocusView: View {
38-
let store: StoreOf<Focus>
35+
@available(tvOS 14.0, *)
36+
struct FocusView: View {
37+
let store: StoreOf<Focus>
3938

40-
@Environment(\.resetFocus) var resetFocus
41-
@Namespace private var namespace
39+
@Environment(\.resetFocus) var resetFocus
40+
@Namespace private var namespace
4241

43-
var body: some View {
44-
WithViewStore(self.store, observe: { $0 }) { viewStore in
45-
VStack(spacing: 100) {
46-
Text(readMe)
47-
.font(.headline)
48-
.multilineTextAlignment(.leading)
49-
.padding()
42+
var body: some View {
43+
WithViewStore(self.store, observe: { $0 }) { viewStore in
44+
VStack(spacing: 100) {
45+
Text(readMe)
46+
.font(.headline)
47+
.multilineTextAlignment(.leading)
48+
.padding()
5049

51-
HStack(spacing: 40) {
52-
ForEach(1..<6) { index in
53-
Button(numbers[index]) {}
54-
.prefersDefaultFocus(viewStore.currentFocus == index, in: self.namespace)
55-
}
50+
HStack(spacing: 40) {
51+
ForEach(1..<6) { index in
52+
Button(numbers[index]) {}
53+
.prefersDefaultFocus(viewStore.currentFocus == index, in: self.namespace)
5654
}
57-
HStack(spacing: 40) {
58-
ForEach(6..<11) { index in
59-
Button(numbers[index]) {}
60-
.prefersDefaultFocus(viewStore.currentFocus == index, in: self.namespace)
61-
}
62-
}
63-
64-
Button("Focus Random") { viewStore.send(.randomButtonClicked) }
6555
}
66-
.onChange(of: viewStore.currentFocus) { _ in
67-
// Update the view's focus when the state tells us the focus changed.
68-
self.resetFocus(in: self.namespace)
56+
HStack(spacing: 40) {
57+
ForEach(6..<11) { index in
58+
Button(numbers[index]) {}
59+
.prefersDefaultFocus(viewStore.currentFocus == index, in: self.namespace)
60+
}
6961
}
70-
.focusScope(self.namespace)
62+
63+
Button("Focus Random") { viewStore.send(.randomButtonClicked) }
7164
}
65+
.onChange(of: viewStore.currentFocus) { _ in
66+
// Update the view's focus when the state tells us the focus changed.
67+
self.resetFocus(in: self.namespace)
68+
}
69+
.focusScope(self.namespace)
7270
}
7371
}
72+
}
7473

75-
@available(tvOS 14.0, *)
76-
struct FocusView_Previews: PreviewProvider {
77-
static var previews: some View {
78-
FocusView(
79-
store: Store(
80-
initialState: Focus.State(),
81-
reducer: Focus()
82-
)
74+
@available(tvOS 14.0, *)
75+
struct FocusView_Previews: PreviewProvider {
76+
static var previews: some View {
77+
FocusView(
78+
store: Store(
79+
initialState: Focus.State(),
80+
reducer: Focus()
8381
)
84-
}
82+
)
8583
}
86-
#endif
84+
}
8785

8886
private let numbers = [
8987
"Zero",

Examples/CaseStudies/tvOSCaseStudies/RootView.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,14 @@ struct RootView: View {
1616

1717
var focusView: AnyView? {
1818
if #available(tvOS 14.0, *) {
19-
#if swift(>=5.3)
20-
return AnyView(
21-
NavigationLink(
22-
"Focus",
23-
destination: FocusView(
24-
store: self.store.scope(state: \.focus, action: Root.Action.focus)
25-
)
19+
return AnyView(
20+
NavigationLink(
21+
"Focus",
22+
destination: FocusView(
23+
store: self.store.scope(state: \.focus, action: Root.Action.focus)
2624
)
2725
)
28-
#else
29-
return nil
30-
#endif
26+
)
3127
} else {
3228
return nil
3329
}

Package.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.5
1+
// swift-tools-version:5.6
22

33
import PackageDescription
44

@@ -21,7 +21,8 @@ let package = Package(
2121
),
2222
],
2323
dependencies: [
24-
.package(name: "Benchmark", url: "https://github.com/google/swift-benchmark", from: "0.1.0"),
24+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
25+
.package(url: "https://github.com/google/swift-benchmark", from: "0.1.0"),
2526
.package(url: "https://github.com/ReactiveCocoa/ReactiveSwift", from: "7.1.0"),
2627
.package(url: "https://github.com/pointfreeco/swift-case-paths", from: "0.8.0"),
2728
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "0.3.0"),
@@ -63,7 +64,7 @@ let package = Package(
6364
name: "swift-composable-architecture-benchmark",
6465
dependencies: [
6566
"ComposableArchitecture",
66-
.product(name: "Benchmark", package: "Benchmark"),
67+
.product(name: "Benchmark", package: "swift-benchmark"),
6768
]
6869
),
6970
]
@@ -79,10 +80,3 @@ let package = Package(
7980
// ])
8081
// )
8182
//}
82-
83-
#if swift(>=5.6)
84-
// Add the documentation compiler plugin if possible
85-
package.dependencies.append(
86-
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")
87-
)
88-
#endif
Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,40 @@
11
import Foundation
22
import XCTestDynamicOverlay
33

4-
#if swift(>=5.6)
5-
extension DependencyValues {
6-
/// The current calendar that features should use when handling dates.
7-
///
8-
/// By default, the calendar returned from `Calendar.autoupdatingCurrent` is supplied. When used
9-
/// in a testing context, access will call to `XCTFail` when invoked, unless explicitly
10-
/// overridden using ``withValue(_:_:operation:)-705n``:
11-
///
12-
/// ```swift
13-
/// DependencyValues.withValue(\.calendar, Calendar(identifier: .gregorian)) {
14-
/// // Assertions...
15-
/// }
16-
/// ```
17-
///
18-
/// Or, if you are using the Composable Architecture, you can override dependencies directly
19-
/// on the `TestStore`:
20-
///
21-
/// ```swift
22-
/// let store = TestStore(
23-
/// initialState: MyFeature.State()
24-
/// reducer: MyFeature()
25-
/// )
26-
///
27-
/// store.dependencies.calendar = Calendar(identifier: .gregorian)
28-
/// ```
29-
public var calendar: Calendar {
30-
get { self[CalendarKey.self] }
31-
set { self[CalendarKey.self] = newValue }
32-
}
4+
extension DependencyValues {
5+
/// The current calendar that features should use when handling dates.
6+
///
7+
/// By default, the calendar returned from `Calendar.autoupdatingCurrent` is supplied. When used
8+
/// in a testing context, access will call to `XCTFail` when invoked, unless explicitly
9+
/// overridden using ``withValue(_:_:operation:)-705n``:
10+
///
11+
/// ```swift
12+
/// DependencyValues.withValue(\.calendar, Calendar(identifier: .gregorian)) {
13+
/// // Assertions...
14+
/// }
15+
/// ```
16+
///
17+
/// Or, if you are using the Composable Architecture, you can override dependencies directly
18+
/// on the `TestStore`:
19+
///
20+
/// ```swift
21+
/// let store = TestStore(
22+
/// initialState: MyFeature.State()
23+
/// reducer: MyFeature()
24+
/// )
25+
///
26+
/// store.dependencies.calendar = Calendar(identifier: .gregorian)
27+
/// ```
28+
public var calendar: Calendar {
29+
get { self[CalendarKey.self] }
30+
set { self[CalendarKey.self] = newValue }
31+
}
3332

34-
private enum CalendarKey: DependencyKey {
35-
static let liveValue = Calendar.autoupdatingCurrent
36-
static var testValue: Calendar {
37-
XCTFail(#"Unimplemented: @Dependency(\.calendar)"#)
38-
return .autoupdatingCurrent
39-
}
33+
private enum CalendarKey: DependencyKey {
34+
static let liveValue = Calendar.autoupdatingCurrent
35+
static var testValue: Calendar {
36+
XCTFail(#"Unimplemented: @Dependency(\.calendar)"#)
37+
return .autoupdatingCurrent
4038
}
4139
}
42-
#endif
40+
}

0 commit comments

Comments
 (0)