diff --git a/Sources/OpenSwiftUI/Core/View/ViewGraph.swift b/Sources/OpenSwiftUI/Core/View/ViewGraph.swift index 067d235e..e4f204a7 100644 --- a/Sources/OpenSwiftUI/Core/View/ViewGraph.swift +++ b/Sources/OpenSwiftUI/Core/View/ViewGraph.swift @@ -47,7 +47,9 @@ final class ViewGraph: GraphHost { // FIXME: TO BE CONFIRMED set { setPreferenceBridge(to: newValue, isInvalidating: newValue == nil) } } + #if canImport(Darwin) // FIXME: See #39 var bridgedPreferences: [(AnyPreferenceKey.Type, OGAttribute)] = [] + #endif // TODO init(rootViewType: Body.Type, requestedOutputs: Outputs) { diff --git a/Sources/OpenSwiftUI/Data/Preference/PreferenceBridge.swift b/Sources/OpenSwiftUI/Data/Preference/PreferenceBridge.swift index 7ac2dffd..2ce12422 100644 --- a/Sources/OpenSwiftUI/Data/Preference/PreferenceBridge.swift +++ b/Sources/OpenSwiftUI/Data/Preference/PreferenceBridge.swift @@ -25,7 +25,8 @@ final class PreferenceBridge { init() { viewGraph = GraphHost.currentHost as! ViewGraph } - + + #if canImport(Darwin) // FIXME: See #39 func addValue(_ value: OGAttribute, for keyType: AnyPreferenceKey.Type) { struct AddValue: PreferenceKeyVisitor { var combiner: OGAttribute @@ -191,6 +192,7 @@ final class PreferenceBridge { } } } + #endif } private struct MergePreferenceKeys: Rule, AsyncAttribute { diff --git a/Sources/OpenSwiftUI/Data/Preference/PreferencesCombiner.swift b/Sources/OpenSwiftUI/Data/Preference/PreferencesCombiner.swift index 5e8a0d74..c3f99fe5 100644 --- a/Sources/OpenSwiftUI/Data/Preference/PreferencesCombiner.swift +++ b/Sources/OpenSwiftUI/Data/Preference/PreferencesCombiner.swift @@ -42,6 +42,7 @@ struct HostPreferencesCombiner: Rule, AsyncAttribute { @WeakAttribute var values: PreferenceList? } + #if canImport(Darwin) // FIXME: See #39 mutating func addChild(keys: Attribute, values: Attribute) { let weakKeys = OGWeakAttribute(keys.identifier) let weakValues = OGWeakAttribute(values.identifier) @@ -52,6 +53,7 @@ struct HostPreferencesCombiner: Rule, AsyncAttribute { children.append(child) } } + #endif private struct CombineValues: PreferenceKeyVisitor { var children: [Child] diff --git a/Sources/OpenSwiftUI/Data/Preference/PreferencesOutputs.swift b/Sources/OpenSwiftUI/Data/Preference/PreferencesOutputs.swift index 33a9c934..c2f98712 100644 --- a/Sources/OpenSwiftUI/Data/Preference/PreferencesOutputs.swift +++ b/Sources/OpenSwiftUI/Data/Preference/PreferencesOutputs.swift @@ -11,16 +11,17 @@ internal import OpenGraphShims struct PreferencesOutputs { private var preferences: [KeyValue] = [] private var debugProperties: _ViewDebug.Properties = [] - - func contains(_ key: Key.Type) -> Bool { + + func contains(_: Key.Type) -> Bool { contains(_AnyPreferenceKey.self) } - + func contains(_ key: AnyPreferenceKey.Type) -> Bool { preferences.contains { $0.key == key } } - - subscript(_ keyType: Key.Type) -> Attribute? { + + #if canImport(Darwin) // FIXME: See #39 + subscript(_: Key.Type) -> Attribute? { get { let value = self[anyKey: _AnyPreferenceKey.self] return value.map { Attribute(identifier: $0) } @@ -29,7 +30,7 @@ struct PreferencesOutputs { self[anyKey: _AnyPreferenceKey.self] = newValue?.identifier } } - + subscript(anyKey keyType: AnyPreferenceKey.Type) -> OGAttribute? { get { preferences.first { $0.key == keyType }?.value } set { @@ -51,11 +52,19 @@ struct PreferencesOutputs { } } } + #else + subscript(_: Key.Type) -> Attribute? { + get { fatalError("See #39") } + set { fatalError("See #39") } + } + #endif } extension PreferencesOutputs { private struct KeyValue { var key: AnyPreferenceKey.Type + #if canImport(Darwin) // FIXME: See #39 var value: OGAttribute + #endif } }