diff --git a/Sources/SketchKit/Constrainable.swift b/Sources/SketchKit/Constrainable.swift index 734140d..4f4e7e6 100644 --- a/Sources/SketchKit/Constrainable.swift +++ b/Sources/SketchKit/Constrainable.swift @@ -55,9 +55,11 @@ extension View: Constrainable { } /// A layout guide that dynamically adjusts to the keyboard's frame. +#if os(iOS) public var keyboardLayout: LayoutGuide { return SketchKitDSL(constrainable: self).resolveKeyboardLayoutGuide() } +#endif } /// LayoutGuide is an abstraction of Apple layout system diff --git a/Sources/SketchKit/KeyboardLayoutGuide.swift b/Sources/SketchKit/KeyboardLayoutGuide.swift index 55b1076..d6e1d74 100644 --- a/Sources/SketchKit/KeyboardLayoutGuide.swift +++ b/Sources/SketchKit/KeyboardLayoutGuide.swift @@ -6,6 +6,7 @@ // Copyright (c) 2021 Anykey Entertrainment. All rights reserved. // +#if os(iOS) import Foundation import UIKit @@ -139,3 +140,4 @@ extension Notification { return self.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? CGFloat } } +#endif diff --git a/Sources/SketchKit/SketchKitDSL.swift b/Sources/SketchKit/SketchKitDSL.swift index 18c5a9f..b659ed7 100644 --- a/Sources/SketchKit/SketchKitDSL.swift +++ b/Sources/SketchKit/SketchKitDSL.swift @@ -56,6 +56,7 @@ public class SketchKitDSL { block(self.constrainable) } +#if os(iOS) func resolveKeyboardLayoutGuide() -> LayoutGuide { guard let view = constrainable as? View else { return LayoutGuide() } @@ -74,4 +75,5 @@ public class SketchKitDSL { return keyboardLayoutGuide } +#endif }