Skip to content

Commit b5719bf

Browse files
authored
Update example app entry points and some minor changes (pointfreeco#859)
* TicTacToe Readme updates * Use new .catchToEffect(_ transform:) in example * Added Todos Readme * Added VoiceMemos Readme wip * Updated VoiceMomos Readme * Updated Todos Readme * Added value to animation modifier * Update VoiceMemos entry point * Update Todos entry point * Update Search entry point * Update SpeechRecognition entry point * Updated SpeechRecognition models * Revert "Updated SpeechRecognition models" This reverts commit dc77e7a.
1 parent 1437951 commit b5719bf

File tree

19 files changed

+131
-185
lines changed

19 files changed

+131
-185
lines changed

Examples/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ This directory holds many case studies and applications to demonstrate solving v
1212
<br> This application uses Apple's Speech framework to demonstrate how to wrap complex dependencies in the `Effect` type of the Composable Architecture. Doing a little bit of upfront work allows you to interact with the dependencies in a controlled, understandable way, and you can write tests on how the dependency interacts with your application logic.
1313

1414
* **Tic-Tac-Toe**
15-
<br> Builds a moderately complex application in both SwiftUI and UIKit that is fully controlled by the Composable Architecture. The core application logic is put into its own modules, with no UI, and then both of the SwiftUI and UIKit applications are run off of that single source of logic. This demonstrates how one can hyper-modularize an application, which for a big enough application can greatly help compile times and developer productivity. This demo was inspired by the equivalent demos in [RIBs](http://github.com/uber/RIBs) (see [here](https://github.com/uber/RIBs/tree/master/ios/tutorials/tutorial4-completed)) and [Workflow](https://github.com/square/workflow/) (see [here](https://github.com/square/workflow/tree/master/swift/Samples/TicTacToe)).
15+
<br> Builds a moderately complex application in both SwiftUI and UIKit that is fully controlled by the Composable Architecture. The core application logic is put into its own modules, with no UI, and then both of the SwiftUI and UIKit applications are run off of that single source of logic. This demonstrates how one can hyper-modularize an application, which for a big enough application can greatly help compile times and developer productivity. This demo was inspired by the equivalent demos in [RIBs](http://github.com/uber/RIBs) (see [here](https://github.com/uber/RIBs/tree/master/ios/tutorials/tutorial4-completed)) and [Workflow](https://github.com/square/workflow/) (see [here](https://github.com/square/workflow-swift/tree/main/Samples/TicTacToe)).
1616

17-
* **Todo**
17+
* **Todos**
1818
<br> A simple todo application with a few bells and whistles, and a comprehensive test suite.
1919

2020
* **Voice Memos**

Examples/Search/Search.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
CA66690B242547B000A639B3 /* WeatherClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA66690A242547B000A639B3 /* WeatherClient.swift */; };
11-
CA86E49D24253C2500357AD9 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA86E49C24253C2500357AD9 /* SceneDelegate.swift */; };
11+
CA86E49D24253C2500357AD9 /* SearchApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA86E49C24253C2500357AD9 /* SearchApp.swift */; };
1212
CA86E49F24253C2500357AD9 /* SearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA86E49E24253C2500357AD9 /* SearchView.swift */; };
1313
CA86E4A124253C2700357AD9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CA86E4A024253C2700357AD9 /* Assets.xcassets */; };
1414
CA86E4B224253C2700357AD9 /* SearchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA86E4B124253C2700357AD9 /* SearchTests.swift */; };
@@ -51,7 +51,7 @@
5151
/* Begin PBXFileReference section */
5252
CA66690A242547B000A639B3 /* WeatherClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherClient.swift; sourceTree = "<group>"; };
5353
CA86E49724253C2500357AD9 /* Search.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Search.app; sourceTree = BUILT_PRODUCTS_DIR; };
54-
CA86E49C24253C2500357AD9 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
54+
CA86E49C24253C2500357AD9 /* SearchApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchApp.swift; sourceTree = "<group>"; };
5555
CA86E49E24253C2500357AD9 /* SearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchView.swift; sourceTree = "<group>"; };
5656
CA86E4A024253C2700357AD9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
5757
CA86E4A824253C2700357AD9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -104,8 +104,8 @@
104104
isa = PBXGroup;
105105
children = (
106106
CA86E4A824253C2700357AD9 /* Info.plist */,
107+
CA86E49C24253C2500357AD9 /* SearchApp.swift */,
107108
CA86E49E24253C2500357AD9 /* SearchView.swift */,
108-
CA86E49C24253C2500357AD9 /* SceneDelegate.swift */,
109109
CA66690A242547B000A639B3 /* WeatherClient.swift */,
110110
CA86E4A024253C2700357AD9 /* Assets.xcassets */,
111111
);
@@ -229,7 +229,7 @@
229229
buildActionMask = 2147483647;
230230
files = (
231231
CA66690B242547B000A639B3 /* WeatherClient.swift in Sources */,
232-
CA86E49D24253C2500357AD9 /* SceneDelegate.swift in Sources */,
232+
CA86E49D24253C2500357AD9 /* SearchApp.swift in Sources */,
233233
CA86E49F24253C2500357AD9 /* SearchView.swift in Sources */,
234234
);
235235
runOnlyForDeploymentPostprocessing = 0;

Examples/Search/Search/SceneDelegate.swift

-39
This file was deleted.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import ComposableArchitecture
2+
import SwiftUI
3+
4+
@main
5+
struct SearchApp: App {
6+
var body: some Scene {
7+
WindowGroup {
8+
SearchView(
9+
store: Store(
10+
initialState: SearchState(),
11+
reducer: searchReducer.debug(),
12+
environment: SearchEnvironment(
13+
weatherClient: WeatherClient.live,
14+
mainQueue: .main
15+
)
16+
)
17+
)
18+
}
19+
}
20+
}

Examples/SpeechRecognition/SpeechRecognition.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
CA2332102447ACFA00B818EB /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA23320F2447ACFA00B818EB /* SceneDelegate.swift */; };
10+
CA2332102447ACFA00B818EB /* SpeechRecognitionApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA23320F2447ACFA00B818EB /* SpeechRecognitionApp.swift */; };
1111
CA2332122447ACFA00B818EB /* SpeechRecognition.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2332112447ACFA00B818EB /* SpeechRecognition.swift */; };
1212
CA2332142447ACFB00B818EB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CA2332132447ACFB00B818EB /* Assets.xcassets */; };
1313
CA2332252447ACFC00B818EB /* SpeechRecognitionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2332242447ACFC00B818EB /* SpeechRecognitionTests.swift */; };
@@ -53,7 +53,7 @@
5353

5454
/* Begin PBXFileReference section */
5555
CA23320A2447ACFA00B818EB /* SpeechRecognition.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SpeechRecognition.app; sourceTree = BUILT_PRODUCTS_DIR; };
56-
CA23320F2447ACFA00B818EB /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
56+
CA23320F2447ACFA00B818EB /* SpeechRecognitionApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpeechRecognitionApp.swift; sourceTree = "<group>"; };
5757
CA2332112447ACFA00B818EB /* SpeechRecognition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpeechRecognition.swift; sourceTree = "<group>"; };
5858
CA2332132447ACFB00B818EB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
5959
CA23321B2447ACFB00B818EB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -110,8 +110,8 @@
110110
isa = PBXGroup;
111111
children = (
112112
CACC04252447DBA3000C5725 /* SpeechClient */,
113-
CA23320F2447ACFA00B818EB /* SceneDelegate.swift */,
114113
CA2332112447ACFA00B818EB /* SpeechRecognition.swift */,
114+
CA23320F2447ACFA00B818EB /* SpeechRecognitionApp.swift */,
115115
CA2332132447ACFB00B818EB /* Assets.xcassets */,
116116
CA23321B2447ACFB00B818EB /* Info.plist */,
117117
);
@@ -245,7 +245,7 @@
245245
files = (
246246
CACC04242447D96D000C5725 /* Live.swift in Sources */,
247247
CACC04292447DF0B000C5725 /* Failing.swift in Sources */,
248-
CA2332102447ACFA00B818EB /* SceneDelegate.swift in Sources */,
248+
CA2332102447ACFA00B818EB /* SpeechRecognitionApp.swift in Sources */,
249249
CA2332122447ACFA00B818EB /* SpeechRecognition.swift in Sources */,
250250
CACC04222447C66C000C5725 /* Client.swift in Sources */,
251251
CACC04272447DBAF000C5725 /* Models.swift in Sources */,

Examples/SpeechRecognition/SpeechRecognition/SceneDelegate.swift

-38
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import ComposableArchitecture
2+
import SwiftUI
3+
4+
@main
5+
struct SpeechRecognitionApp: App {
6+
var body: some Scene {
7+
WindowGroup {
8+
SpeechRecognitionView(
9+
store: Store(
10+
initialState: .init(),
11+
reducer: appReducer,
12+
environment: AppEnvironment(
13+
mainQueue: .main,
14+
speechClient: .live
15+
)
16+
)
17+
)
18+
}
19+
}
20+
}

Examples/TicTacToe/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Tic-Tac-Toe
22

3-
This example demonstrates how to build a full, moderately complex application in the Composable Architecture. It is based off the Tic-Tac-Toe examples used to demonstrate [RIBs](https://github.com/uber/RIBs) from Uber ([see here](https://github.com/uber/RIBs/tree/master/ios/tutorials)) and [Workflows](https://github.com/square/workflow) from Square ([see here](https://github.com/square/workflow/tree/master/swift/Samples/TicTacToe)).
3+
This example demonstrates how to build a full, moderately complex application in the Composable Architecture. It is based off the Tic-Tac-Toe examples used to demonstrate [RIBs](https://github.com/uber/RIBs) from Uber ([see here](https://github.com/uber/RIBs/tree/master/ios/tutorials)) and [Workflows](https://github.com/square/workflow) from Square ([see here](https://github.com/square/workflow-swift/tree/main/Samples/TicTacToe)).
44

55
It shows many real-world use cases and best practices that we encounter when building applications:
66

Examples/Todos/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Todos
2+
3+
This simple todo application built with the Composable Architecture includes a few bells and whistles:
4+
5+
* Filtering and rearranging todo items.
6+
* Automatically sort completed todos to the bottom of the list.
7+
* Debouncing the sort action to allow multiple todo items to be toggled before being sorted.
8+
* A comprehensive test suite.

Examples/Todos/Todos.xcodeproj/project.pbxproj

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
CA93D060249BF4D000A6F65D /* Todo.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA93D05F249BF4D000A6F65D /* Todo.swift */; };
1111
DC1394322469E57000EE1157 /* ComposableArchitecture in Frameworks */ = {isa = PBXBuildFile; productRef = DC1394312469E57000EE1157 /* ComposableArchitecture */; };
12-
DCBCB77624290F6C00DE1F59 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCBCB77524290F6C00DE1F59 /* SceneDelegate.swift */; };
12+
DCBCB77624290F6C00DE1F59 /* TodosApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCBCB77524290F6C00DE1F59 /* TodosApp.swift */; };
1313
DCBCB77A24290F6D00DE1F59 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DCBCB77924290F6D00DE1F59 /* Assets.xcassets */; };
1414
DCBCB78B24290F6D00DE1F59 /* TodosTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCBCB78A24290F6D00DE1F59 /* TodosTests.swift */; };
1515
DCBCB79B24290FEB00DE1F59 /* Todos.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCBCB79A24290FEB00DE1F59 /* Todos.swift */; };
@@ -49,10 +49,11 @@
4949
/* End PBXCopyFilesBuildPhase section */
5050

5151
/* Begin PBXFileReference section */
52+
23EDBE6A271CD8C7004F7430 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
5253
CA93D05F249BF4D000A6F65D /* Todo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Todo.swift; sourceTree = "<group>"; };
5354
DC85B441242D0286009784B0 /* swift-composable-architecture */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "swift-composable-architecture"; path = ../..; sourceTree = "<group>"; };
5455
DCBCB77024290F6C00DE1F59 /* Todos.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Todos.app; sourceTree = BUILT_PRODUCTS_DIR; };
55-
DCBCB77524290F6C00DE1F59 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
56+
DCBCB77524290F6C00DE1F59 /* TodosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodosApp.swift; sourceTree = "<group>"; };
5657
DCBCB77924290F6D00DE1F59 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
5758
DCBCB78124290F6D00DE1F59 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5859
DCBCB78624290F6D00DE1F59 /* TodosTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TodosTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -83,6 +84,7 @@
8384
isa = PBXGroup;
8485
children = (
8586
DC85B441242D0286009784B0 /* swift-composable-architecture */,
87+
23EDBE6A271CD8C7004F7430 /* README.md */,
8688
DCBCB77124290F6C00DE1F59 /* Products */,
8789
DCBCB77224290F6C00DE1F59 /* Todos */,
8890
DCBCB78924290F6D00DE1F59 /* TodosTests */,
@@ -102,9 +104,9 @@
102104
isa = PBXGroup;
103105
children = (
104106
DCBCB78124290F6D00DE1F59 /* Info.plist */,
105-
DCBCB77524290F6C00DE1F59 /* SceneDelegate.swift */,
106107
CA93D05F249BF4D000A6F65D /* Todo.swift */,
107108
DCBCB79A24290FEB00DE1F59 /* Todos.swift */,
109+
DCBCB77524290F6C00DE1F59 /* TodosApp.swift */,
108110
DCBCB77924290F6D00DE1F59 /* Assets.xcassets */,
109111
);
110112
path = Todos;
@@ -226,7 +228,7 @@
226228
isa = PBXSourcesBuildPhase;
227229
buildActionMask = 2147483647;
228230
files = (
229-
DCBCB77624290F6C00DE1F59 /* SceneDelegate.swift in Sources */,
231+
DCBCB77624290F6C00DE1F59 /* TodosApp.swift in Sources */,
230232
CA93D060249BF4D000A6F65D /* Todo.swift in Sources */,
231233
DCBCB79B24290FEB00DE1F59 /* Todos.swift in Sources */,
232234
);

Examples/Todos/Todos/SceneDelegate.swift

-39
This file was deleted.

Examples/Todos/Todos/TodosApp.swift

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import ComposableArchitecture
2+
import SwiftUI
3+
4+
@main
5+
struct TodosApp: App {
6+
var body: some Scene {
7+
WindowGroup {
8+
AppView(
9+
store: Store(
10+
initialState: AppState(),
11+
reducer: appReducer,
12+
environment: AppEnvironment(
13+
mainQueue: .main,
14+
uuid: UUID.init
15+
)
16+
)
17+
)
18+
}
19+
}
20+
}

Examples/VoiceMemos/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Voice Memos
2+
3+
This application demonstrates how to work with multiple dependencies and manage a complex state machine driven off of timers in the Composable Architecture. Some functionality includes:
4+
5+
* Requesting the user’s permission to record audio.
6+
* Prompting the user if insufficient permission is provided.
7+
* Audio recording and playback.
8+
* Handling errors that may occur during recording or playback.
9+
* Stubbing dependencies to work with SwiftUI previews.

0 commit comments

Comments
 (0)