Skip to content

Commit 57e804f

Browse files
stephencelismbrandonwMatejkobjessetipton
authored
Macro bonanza (#2553)
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Silence test warnings * wip * wip * wip * update a bunch of docs * wip * wip * fix * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Kill integration tests for now * wip * wip * wip * wip * updating docs for @Reducer macro * replaced more Reducer protocols with @Reducer * Fixed some broken docc references * wip * Some @Reducer docs * more docs * convert some old styles to new style * wip * wip * wip * wip * wip * wip * wip * bump * update tutorials to use body * update tutorials to use DML on destination state enum * Add diagnostic * wip * updated a few more tests * wip * wip * Add another gotcha * wip * wip * wip * fixes * wip * wip * wip * wip * wip * fix * wip * remove for now * wip * wip * updated some docs * migration guides * more migration guide * fix ci * fix * soft deprecate all apis using AnyCasePath * wip * Fix * fix tests * swift-format 509 compatibility * wip * wip * Update Sources/ComposableArchitecture/Macros.swift Co-authored-by: Mateusz Bąk <[email protected]> * wip * wip * update optional state case study * remove initializer * Don't use @State for BasicsView integration demo * fix tests * remove reduce diagnostics for now * diagnose error not warning * Update Sources/ComposableArchitecture/Macros.swift Co-authored-by: Jesse Tipton <[email protected]> * wip * move integration tests to cron * Revert "move integration tests to cron" This reverts commit f9bdf2f. * disable flakey tests on CI * wip * wip * Revert "Revert "move integration tests to cron"" This reverts commit 66aafa7. * fix * wip * fix --------- Co-authored-by: Brandon Williams <[email protected]> Co-authored-by: Mateusz Bąk <[email protected]> Co-authored-by: Brandon Williams <[email protected]> Co-authored-by: Jesse Tipton <[email protected]>
1 parent 0decea3 commit 57e804f

File tree

311 files changed

+6085
-3611
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

311 files changed

+6085
-3611
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
- case-key-paths
87
pull_request:
98
branches:
109
- '*'
@@ -59,13 +58,3 @@ jobs:
5958
run: sudo xcode-select -s /Applications/Xcode_15.0.1.app
6059
- name: Run tests
6160
run: make test-examples
62-
63-
integration:
64-
name: Integration
65-
runs-on: macos-13
66-
steps:
67-
- uses: actions/checkout@v4
68-
- name: Select Xcode 15
69-
run: sudo xcode-select -s /Applications/Xcode_15.0.1.app
70-
- name: Run tests
71-
run: make test-integration

.github/workflows/scheduled-ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
on:
2+
schedule:
3+
- cron: '30 8 * * *'
4+
- cron: '30 20 * * *'
5+
6+
jobs:
7+
integration:
8+
name: Integration
9+
runs-on: macos-13
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Select Xcode 15
13+
run: sudo xcode-select -s /Applications/Xcode_15.0.1.app
14+
- name: Run tests
15+
run: make test-integration

.spi.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ builder:
1010
- platform: watchos
1111
scheme: ComposableArchitecture
1212
- documentation_targets: [ComposableArchitecture]
13+
swift_version: 5.9

ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved

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

ComposableArchitecture.xcworkspace/xcshareddata/xcschemes/ComposableArchitecture.xcscheme

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@
3939
ReferencedContainer = "container:">
4040
</BuildableReference>
4141
</TestableReference>
42+
<TestableReference
43+
skipped = "NO">
44+
<BuildableReference
45+
BuildableIdentifier = "primary"
46+
BlueprintIdentifier = "ComposableArchitectureMacrosTests"
47+
BuildableName = "ComposableArchitectureMacrosTests"
48+
BlueprintName = "ComposableArchitectureMacrosTests"
49+
ReferencedContainer = "container:">
50+
</BuildableReference>
51+
</TestableReference>
4252
</Testables>
4353
</TestAction>
4454
<LaunchAction

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-AlertsAndConfirmationDialogs.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,24 @@ private let readMe = """
2121

2222
// MARK: - Feature domain
2323

24-
struct AlertAndConfirmationDialog: Reducer {
24+
@Reducer
25+
struct AlertAndConfirmationDialog {
2526
struct State: Equatable {
2627
@PresentationState var alert: AlertState<Action.Alert>?
2728
@PresentationState var confirmationDialog: ConfirmationDialogState<Action.ConfirmationDialog>?
2829
var count = 0
2930
}
3031

31-
enum Action: Equatable {
32+
enum Action {
3233
case alert(PresentationAction<Alert>)
3334
case alertButtonTapped
3435
case confirmationDialog(PresentationAction<ConfirmationDialog>)
3536
case confirmationDialogButtonTapped
3637

37-
enum Alert: Equatable {
38+
enum Alert {
3839
case incrementButtonTapped
3940
}
40-
enum ConfirmationDialog: Equatable {
41+
enum ConfirmationDialog {
4142
case incrementButtonTapped
4243
case decrementButtonTapped
4344
}
@@ -97,8 +98,8 @@ struct AlertAndConfirmationDialog: Reducer {
9798
return .none
9899
}
99100
}
100-
.ifLet(\.$alert, action: /Action.alert)
101-
.ifLet(\.$confirmationDialog, action: /Action.confirmationDialog)
101+
.ifLet(\.$alert, action: \.alert)
102+
.ifLet(\.$confirmationDialog, action: \.confirmationDialog)
102103
}
103104
}
104105

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Animations.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,24 @@ private let readMe = """
2020

2121
// MARK: - Feature domain
2222

23-
struct Animations: Reducer {
23+
@Reducer
24+
struct Animations {
2425
struct State: Equatable {
2526
@PresentationState var alert: AlertState<Action.Alert>?
2627
var circleCenter: CGPoint?
2728
var circleColor = Color.black
2829
var isCircleScaled = false
2930
}
3031

31-
enum Action: Equatable, Sendable {
32+
enum Action: Sendable {
3233
case alert(PresentationAction<Alert>)
3334
case circleScaleToggleChanged(Bool)
3435
case rainbowButtonTapped
3536
case resetButtonTapped
3637
case setColor(Color)
3738
case tapped(CGPoint)
3839

39-
enum Alert: Equatable, Sendable {
40+
enum Alert: Sendable {
4041
case resetConfirmationButtonTapped
4142
}
4243
}
@@ -93,7 +94,7 @@ struct Animations: Reducer {
9394
return .none
9495
}
9596
}
96-
.ifLet(\.$alert, action: /Action.alert)
97+
.ifLet(\.$alert, action: \.alert)
9798
}
9899
}
99100

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Bindings-Basics.swift

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ private let readMe = """
2020

2121
// MARK: - Feature domain
2222

23-
struct BindingBasics: Reducer {
23+
@Reducer
24+
struct BindingBasics {
2425
struct State: Equatable {
2526
var sliderValue = 5.0
2627
var stepCount = 10
@@ -35,24 +36,26 @@ struct BindingBasics: Reducer {
3536
case toggleChanged(isOn: Bool)
3637
}
3738

38-
func reduce(into state: inout State, action: Action) -> Effect<Action> {
39-
switch action {
40-
case let .sliderValueChanged(value):
41-
state.sliderValue = value
42-
return .none
43-
44-
case let .stepCountChanged(count):
45-
state.sliderValue = .minimum(state.sliderValue, Double(count))
46-
state.stepCount = count
47-
return .none
48-
49-
case let .textChanged(text):
50-
state.text = text
51-
return .none
52-
53-
case let .toggleChanged(isOn):
54-
state.toggleIsOn = isOn
55-
return .none
39+
var body: some Reducer<State, Action> {
40+
Reduce { state, action in
41+
switch action {
42+
case let .sliderValueChanged(value):
43+
state.sliderValue = value
44+
return .none
45+
46+
case let .stepCountChanged(count):
47+
state.sliderValue = .minimum(state.sliderValue, Double(count))
48+
state.stepCount = count
49+
return .none
50+
51+
case let .textChanged(text):
52+
state.text = text
53+
return .none
54+
55+
case let .toggleChanged(isOn):
56+
state.toggleIsOn = isOn
57+
return .none
58+
}
5659
}
5760
}
5861
}

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Bindings-Forms.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ private let readMe = """
1515

1616
// MARK: - Feature domain
1717

18-
struct BindingForm: Reducer {
18+
@Reducer
19+
struct BindingForm {
1920
struct State: Equatable {
2021
@BindingState var sliderValue = 5.0
2122
@BindingState var stepCount = 10
2223
@BindingState var text = ""
2324
@BindingState var toggleIsOn = false
2425
}
2526

26-
enum Action: BindableAction, Equatable {
27+
enum Action: BindableAction {
2728
case binding(BindingAction<State>)
2829
case resetButtonTapped
2930
}

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Composition-TwoCounters.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@ private let readMe = """
99

1010
// MARK: - Feature domain
1111

12-
struct TwoCounters: Reducer {
12+
@Reducer
13+
struct TwoCounters {
1314
struct State: Equatable {
1415
var counter1 = Counter.State()
1516
var counter2 = Counter.State()
1617
}
1718

18-
enum Action: Equatable {
19+
enum Action {
1920
case counter1(Counter.Action)
2021
case counter2(Counter.Action)
2122
}
2223

2324
var body: some Reducer<State, Action> {
24-
Scope(state: \.counter1, action: /Action.counter1) {
25+
Scope(state: \.counter1, action: \.counter1) {
2526
Counter()
2627
}
27-
Scope(state: \.counter2, action: /Action.counter2) {
28+
Scope(state: \.counter2, action: \.counter2) {
2829
Counter()
2930
}
3031
}

0 commit comments

Comments
 (0)