From d07212c3d2b7ed802795312e35fed49ea0573b90 Mon Sep 17 00:00:00 2001 From: Dominik Mayer Date: Sat, 28 Dec 2024 21:27:39 +0700 Subject: [PATCH 1/2] Made sure multi-platform project compiles --- Sources/KeyboardShortcuts/Utilities.swift | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Sources/KeyboardShortcuts/Utilities.swift b/Sources/KeyboardShortcuts/Utilities.swift index cd2a8f6..b9dbf2a 100644 --- a/Sources/KeyboardShortcuts/Utilities.swift +++ b/Sources/KeyboardShortcuts/Utilities.swift @@ -507,6 +507,17 @@ extension Dictionary { index(forKey: key) != nil } } + +@available(macOS 11.0, *) +extension KeyEquivalent { + init?(unicodeScalarValue value: Int) { + guard let character = Character(unicodeScalarValue: value) else { + return nil + } + + self = KeyEquivalent(character) + } +} #endif @@ -536,17 +547,6 @@ extension StringProtocol { } } -@available(macOS 11.0, *) -extension KeyEquivalent { - init?(unicodeScalarValue value: Int) { - guard let character = Character(unicodeScalarValue: value) else { - return nil - } - - self = KeyEquivalent(character) - } -} - extension Character { init?(unicodeScalarValue value: Int) { guard let content = UnicodeScalar(value) else { From c86b279658b442ae1ea868a4b65836fa4a9d6279 Mon Sep 17 00:00:00 2001 From: Dominik Mayer Date: Sun, 29 Dec 2024 22:38:57 +0700 Subject: [PATCH 2/2] Made the KeyEquivalent extension available on iOS again --- Sources/KeyboardShortcuts/Utilities.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/KeyboardShortcuts/Utilities.swift b/Sources/KeyboardShortcuts/Utilities.swift index b9dbf2a..defa072 100644 --- a/Sources/KeyboardShortcuts/Utilities.swift +++ b/Sources/KeyboardShortcuts/Utilities.swift @@ -1,6 +1,7 @@ +import SwiftUI + #if os(macOS) import Carbon.HIToolbox -import SwiftUI extension String { @@ -507,7 +508,9 @@ extension Dictionary { index(forKey: key) != nil } } +#endif +@available(iOS 14.0, *) @available(macOS 11.0, *) extension KeyEquivalent { init?(unicodeScalarValue value: Int) { @@ -518,7 +521,6 @@ extension KeyEquivalent { self = KeyEquivalent(character) } } -#endif extension Sequence where Element: Hashable {