Skip to content

Commit d1467db

Browse files
committed
Availability guards.
1 parent ea824f3 commit d1467db

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Sources/ComposableArchitecture/SwiftUI/SwitchStore.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
/// A view that can switch over a store of enum state and handle each case.
@@ -44,6 +45,7 @@ import SwiftUI
4445
/// - See also: `Reducer.pullback`, a method that aids in transforming reducers that operate on each
4546
/// case of an enum into reducers that operate on the entire enum.
4647
///
48+
@available(iOS 13, macOS 10.15, macCatalyst 13, tvOS 13, watchOS 6, *)
4749
public struct SwitchStore<State, Action, Content>: View where Content: View {
4850
public let store: Store<State, Action>
4951
public let content: () -> Content
@@ -63,6 +65,7 @@ public struct SwitchStore<State, Action, Content>: View where Content: View {
6365
}
6466

6567
/// A view that handles a specific case of enum state in a `SwitchStore`.
68+
@available(iOS 13, macOS 10.15, macCatalyst 13, tvOS 13, watchOS 6, *)
6669
public struct CaseLet<GlobalState, GlobalAction, LocalState, LocalAction, Content>: View
6770
where Content: View {
6871
@EnvironmentObject private var store: StoreObservableObject<GlobalState, GlobalAction>
@@ -104,6 +107,7 @@ where Content: View {
104107
/// If you wish to use `SwitchStore` in a non-exhaustive manner (i.e. you do not want to provide
105108
/// a `CaseLet` for each case of the enum), then you must insert a `Default` view at the end of
106109
/// the `SwitchStore`'s body.
110+
@available(iOS 13, macOS 10.15, macCatalyst 13, tvOS 13, watchOS 6, *)
107111
public struct Default<Content>: View where Content: View {
108112
private let content: () -> Content
109113

@@ -121,6 +125,7 @@ public struct Default<Content>: View where Content: View {
121125
}
122126
}
123127

128+
@available(iOS 13, macOS 10.15, macCatalyst 13, tvOS 13, watchOS 6, *)
124129
extension SwitchStore {
125130
public init<State1, Action1, Content1, DefaultContent>(
126131
_ store: Store<State, Action>,
@@ -529,6 +534,7 @@ extension SwitchStore {
529534
}
530535
}
531536

537+
@available(iOS 13, macOS 10.15, macCatalyst 13, tvOS 13, watchOS 6, *)
532538
public struct _ExhaustivityCheckView<State, Action>: View {
533539
@EnvironmentObject private var store: StoreObservableObject<State, Action>
534540
let file: StaticString
@@ -539,7 +545,7 @@ public struct _ExhaustivityCheckView<State, Action>: View {
539545
let message = """
540546
Warning: SwitchStore.body@\(self.file):\(self.line)
541547
542-
"\(debugCaseOutput(self.store.wrappedValue.state.value))" was encountered by a \
548+
"\(debugCaseOutput(self.store.wrappedValue.$state.value))" was encountered by a \
543549
"SwitchStore" that does not handle this case.
544550
545551
Make sure that you exhaustively provide a "CaseLet" view for each case in "\(State.self)", \
@@ -574,6 +580,7 @@ public struct _ExhaustivityCheckView<State, Action>: View {
574580
}
575581
}
576582

583+
@available(iOS 13, macOS 10.15, macCatalyst 13, tvOS 13, watchOS 6, *)
577584
private class StoreObservableObject<State, Action>: ObservableObject {
578585
let wrappedValue: Store<State, Action>
579586

@@ -599,3 +606,4 @@ private struct EnumValueWitnessTable {
599606
let getEnumTag: @convention(c) (UnsafeRawPointer, UnsafeRawPointer) -> UInt32
600607
let f13, f14: UnsafeRawPointer
601608
}
609+
#endif

0 commit comments

Comments
 (0)