From 632620f4debc384c4373f21adc65f4a3b7673898 Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Wed, 1 Jun 2022 16:03:10 +0200 Subject: [PATCH] Add ErrorFeature to example app --- .../xcschemes/ErrorFeature.xcscheme | 78 +++++++++++++++++++ .../xcschemes/example-app.xcscheme | 24 ++++++ Example/ExampleApp/Package.swift | 25 ++++++ .../Sources/ErrorFeature/ErrorFeature.swift | 20 +++++ .../Sources/ErrorFeature/ErrorView.swift | 32 ++++++++ .../ErrorFeatureTests/ErrorFeatureTests.swift | 8 ++ 6 files changed, 187 insertions(+) create mode 100644 Example/ExampleApp/.swiftpm/xcode/xcshareddata/xcschemes/ErrorFeature.xcscheme create mode 100644 Example/ExampleApp/Sources/ErrorFeature/ErrorFeature.swift create mode 100644 Example/ExampleApp/Sources/ErrorFeature/ErrorView.swift create mode 100644 Example/ExampleApp/Tests/ErrorFeatureTests/ErrorFeatureTests.swift diff --git a/Example/ExampleApp/.swiftpm/xcode/xcshareddata/xcschemes/ErrorFeature.xcscheme b/Example/ExampleApp/.swiftpm/xcode/xcshareddata/xcschemes/ErrorFeature.xcscheme new file mode 100644 index 00000000..95ae136e --- /dev/null +++ b/Example/ExampleApp/.swiftpm/xcode/xcshareddata/xcschemes/ErrorFeature.xcscheme @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "1340" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "ErrorFeature" + BuildableName = "ErrorFeature" + BlueprintName = "ErrorFeature" + ReferencedContainer = "container:"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> + <Testables> + <TestableReference + skipped = "NO"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "ErrorFeatureTests" + BuildableName = "ErrorFeatureTests" + BlueprintName = "ErrorFeatureTests" + ReferencedContainer = "container:"> + </BuildableReference> + </TestableReference> + </Testables> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES"> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + <MacroExpansion> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "ErrorFeature" + BuildableName = "ErrorFeature" + BlueprintName = "ErrorFeature" + ReferencedContainer = "container:"> + </BuildableReference> + </MacroExpansion> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/Example/ExampleApp/.swiftpm/xcode/xcshareddata/xcschemes/example-app.xcscheme b/Example/ExampleApp/.swiftpm/xcode/xcshareddata/xcschemes/example-app.xcscheme index 6901d433..ac213623 100644 --- a/Example/ExampleApp/.swiftpm/xcode/xcshareddata/xcschemes/example-app.xcscheme +++ b/Example/ExampleApp/.swiftpm/xcode/xcshareddata/xcschemes/example-app.xcscheme @@ -20,6 +20,20 @@ ReferencedContainer = "container:"> </BuildableReference> </BuildActionEntry> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "ErrorFeature" + BuildableName = "ErrorFeature" + BlueprintName = "ErrorFeature" + ReferencedContainer = "container:"> + </BuildableReference> + </BuildActionEntry> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" @@ -67,6 +81,16 @@ ReferencedContainer = "container:"> </BuildableReference> </TestableReference> + <TestableReference + skipped = "NO"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "ErrorFeatureTests" + BuildableName = "ErrorFeatureTests" + BlueprintName = "ErrorFeatureTests" + ReferencedContainer = "container:"> + </BuildableReference> + </TestableReference> <TestableReference skipped = "NO"> <BuildableReference diff --git a/Example/ExampleApp/Package.swift b/Example/ExampleApp/Package.swift index e8881f2e..9f02c271 100644 --- a/Example/ExampleApp/Package.swift +++ b/Example/ExampleApp/Package.swift @@ -24,6 +24,10 @@ let package = Package( name: "AppFeature", targets: ["AppFeature"] ), + .library( + name: "ErrorFeature", + targets: ["ErrorFeature"] + ), .library( name: "LandingFeature", targets: ["LandingFeature"] @@ -80,6 +84,27 @@ let package = Package( ], swiftSettings: swiftSettings ), + .target( + name: "ErrorFeature", + dependencies: [ + .product( + name: "ComposableArchitecture", + package: "swift-composable-architecture" + ), + .product( + name: "ElixxirDAppsSDK", + package: "elixxir-dapps-sdk-swift" + ), + ], + swiftSettings: swiftSettings + ), + .testTarget( + name: "ErrorFeatureTests", + dependencies: [ + .target(name: "ErrorFeature"), + ], + swiftSettings: swiftSettings + ), .target( name: "LandingFeature", dependencies: [ diff --git a/Example/ExampleApp/Sources/ErrorFeature/ErrorFeature.swift b/Example/ExampleApp/Sources/ErrorFeature/ErrorFeature.swift new file mode 100644 index 00000000..7490e1da --- /dev/null +++ b/Example/ExampleApp/Sources/ErrorFeature/ErrorFeature.swift @@ -0,0 +1,20 @@ +import ComposableArchitecture +import SwiftUI + +public struct ErrorState: Equatable { + public init() {} +} + +public enum ErrorAction: Equatable {} + +public struct ErrorEnvironment { + public init() {} +} + +public let errorReducer = Reducer<ErrorState, ErrorAction, ErrorEnvironment>.empty + +#if DEBUG +extension ErrorEnvironment { + public static let failing = ErrorEnvironment() +} +#endif diff --git a/Example/ExampleApp/Sources/ErrorFeature/ErrorView.swift b/Example/ExampleApp/Sources/ErrorFeature/ErrorView.swift new file mode 100644 index 00000000..bc86d99c --- /dev/null +++ b/Example/ExampleApp/Sources/ErrorFeature/ErrorView.swift @@ -0,0 +1,32 @@ +import ComposableArchitecture +import SwiftUI + +public struct ErrorView: View { + public init(store: Store<ErrorState, ErrorAction>) { + self.store = store + } + + let store: Store<ErrorState, ErrorAction> + + struct ViewState: Equatable { + init(state: ErrorState) {} + } + + public var body: some View { + WithViewStore(store.scope(state: ViewState.init)) { viewStore in + Text("ErrorView") + } + } +} + +#if DEBUG +public struct ErrorView_Previews: PreviewProvider { + public static var previews: some View { + ErrorView(store: .init( + initialState: .init(), + reducer: .empty, + environment: () + )) + } +} +#endif diff --git a/Example/ExampleApp/Tests/ErrorFeatureTests/ErrorFeatureTests.swift b/Example/ExampleApp/Tests/ErrorFeatureTests/ErrorFeatureTests.swift new file mode 100644 index 00000000..50dabc30 --- /dev/null +++ b/Example/ExampleApp/Tests/ErrorFeatureTests/ErrorFeatureTests.swift @@ -0,0 +1,8 @@ +import XCTest +@testable import ErrorFeature + +final class ErrorFeatureTests: XCTestCase { + func testExample() { + XCTAssert(true) + } +} -- GitLab