From 4d417fe2cced7988cff314e0f036969bd99f55ab Mon Sep 17 00:00:00 2001 From: Akring Date: Fri, 29 Mar 2024 21:33:36 +0800 Subject: [PATCH] fix: Add #if os(macOS) macro --- Lib/Sauce/InputSource.swift | 2 ++ Lib/Sauce/Key.swift | 2 ++ Lib/Sauce/KeyboardLayout.swift | 2 ++ Lib/Sauce/ModifierTransformer.swift | 2 ++ Lib/Sauce/NSMenuItem+Key.swift | 2 ++ Lib/Sauce/Sauce.swift | 2 ++ Lib/Sauce/SpecialKeyCode.swift | 2 ++ Lib/Sauce/TISInputSource+Property.swift | 2 ++ 8 files changed, 16 insertions(+) diff --git a/Lib/Sauce/InputSource.swift b/Lib/Sauce/InputSource.swift index 49b553b..8b66363 100644 --- a/Lib/Sauce/InputSource.swift +++ b/Lib/Sauce/InputSource.swift @@ -8,6 +8,7 @@ // Copyright © 2015-2020 Clipy Project. // +#if os(macOS) import Foundation import Carbon @@ -56,3 +57,4 @@ extension InputSource: Equatable { lhs.modeID == rhs.modeID } } +#endif diff --git a/Lib/Sauce/Key.swift b/Lib/Sauce/Key.swift index 7dceb80..698c93d 100644 --- a/Lib/Sauce/Key.swift +++ b/Lib/Sauce/Key.swift @@ -8,6 +8,7 @@ // Copyright © 2015-2020 Clipy Project. // +#if os(macOS) import Foundation import Carbon @@ -561,3 +562,4 @@ public enum Key: String, Codable, Equatable { } } +#endif diff --git a/Lib/Sauce/KeyboardLayout.swift b/Lib/Sauce/KeyboardLayout.swift index 1982144..6411bf6 100644 --- a/Lib/Sauce/KeyboardLayout.swift +++ b/Lib/Sauce/KeyboardLayout.swift @@ -8,6 +8,7 @@ // Copyright © 2015-2020 Clipy Project. // +#if os(macOS) import Foundation import Carbon @@ -186,3 +187,4 @@ private extension KeyboardLayout { return NSString(characters: &chars, length: length) as String } } +#endif diff --git a/Lib/Sauce/ModifierTransformer.swift b/Lib/Sauce/ModifierTransformer.swift index 12cfc59..cb26423 100644 --- a/Lib/Sauce/ModifierTransformer.swift +++ b/Lib/Sauce/ModifierTransformer.swift @@ -8,6 +8,7 @@ // Copyright © 2015-2020 Clipy Project. // +#if os(macOS) import Foundation import Carbon import AppKit @@ -44,3 +45,4 @@ extension ModifierTransformer { return convertedCarbonModifiers } } +#endif diff --git a/Lib/Sauce/NSMenuItem+Key.swift b/Lib/Sauce/NSMenuItem+Key.swift index 4750f2e..6711360 100644 --- a/Lib/Sauce/NSMenuItem+Key.swift +++ b/Lib/Sauce/NSMenuItem+Key.swift @@ -8,6 +8,7 @@ // Copyright © 2015-2020 Clipy Project. // +#if os(macOS) import AppKit extension NSMenuItem { @@ -21,3 +22,4 @@ extension NSMenuItem { return Key(character: keyEquivalent, virtualKeyCode: nil) } } +#endif diff --git a/Lib/Sauce/Sauce.swift b/Lib/Sauce/Sauce.swift index 3eba989..38ec3ad 100644 --- a/Lib/Sauce/Sauce.swift +++ b/Lib/Sauce/Sauce.swift @@ -8,6 +8,7 @@ // Copyright © 2015-2020 Clipy Project. // +#if os(macOS) import Foundation import AppKit @@ -112,3 +113,4 @@ extension Sauce { return character(with: source, keyCode: keyCode, carbonModifiers: modifierTransformar.carbonFlags(from: cocoaModifiers)) } } +#endif diff --git a/Lib/Sauce/SpecialKeyCode.swift b/Lib/Sauce/SpecialKeyCode.swift index 3895905..e08a199 100644 --- a/Lib/Sauce/SpecialKeyCode.swift +++ b/Lib/Sauce/SpecialKeyCode.swift @@ -8,6 +8,7 @@ // Copyright © 2015-2020 Clipy Project. // +#if os(macOS) import Foundation import Carbon @@ -157,3 +158,4 @@ private extension Int { return String(format: "%C", self) } } +#endif diff --git a/Lib/Sauce/TISInputSource+Property.swift b/Lib/Sauce/TISInputSource+Property.swift index bb26a0e..953b77d 100644 --- a/Lib/Sauce/TISInputSource+Property.swift +++ b/Lib/Sauce/TISInputSource+Property.swift @@ -8,6 +8,7 @@ // Copyright © 2015-2020 Clipy Project. // +#if os(macOS) import Foundation import Carbon @@ -17,3 +18,4 @@ extension TISInputSource { return Unmanaged.fromOpaque(value).takeUnretainedValue() as? T } } +#endif