From f4f8f8e86be19675a7e49365d6af3bd67893cfee Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 9 Jan 2023 17:19:43 +0000 Subject: [PATCH] iOS: Fix build issues with Xcode 10.1 --- .../native/juce_ios_Audio.cpp | 5 ++-- .../native/juce_ios_UIViewComponentPeer.mm | 26 ++++++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/juce_audio_devices/native/juce_ios_Audio.cpp b/modules/juce_audio_devices/native/juce_ios_Audio.cpp index edf1db75dd..9789e2a31c 100644 --- a/modules/juce_audio_devices/native/juce_ios_Audio.cpp +++ b/modules/juce_audio_devices/native/juce_ios_Audio.cpp @@ -701,12 +701,13 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") Image getIcon (int size) { + #if TARGET_OS_MACCATALYST if (@available (macCatalyst 14.0, *)) + #endif { if (interAppAudioConnected) { - UIImage* hostUIImage = AudioOutputUnitGetHostIcon (audioUnit, size); - if (hostUIImage != nullptr) + if (UIImage* hostUIImage = AudioOutputUnitGetHostIcon (audioUnit, size)) return juce_createImageFromUIImage (hostUIImage); } } diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index 3d40104a7f..33b90e3caf 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -77,7 +77,6 @@ class UIViewComponentPeer; namespace iOSGlobals { -#if JUCE_HAS_IOS_HARDWARE_KEYBOARD_SUPPORT class KeysCurrentlyDown { public: @@ -95,7 +94,6 @@ private: std::set down; }; static KeysCurrentlyDown keysCurrentlyDown; -#endif static UIViewComponentPeer* currentlyFocusedPeer = nullptr; } // namespace iOSGlobals @@ -797,13 +795,19 @@ static std::optional getKeyCodeForSpecialCharacterString (StringRef charact { static const auto map = [&] { - std::map result { { nsStringToJuce (UIKeyInputUpArrow), KeyPress::upKey }, - { nsStringToJuce (UIKeyInputDownArrow), KeyPress::downKey }, - { nsStringToJuce (UIKeyInputLeftArrow), KeyPress::leftKey }, - { nsStringToJuce (UIKeyInputRightArrow), KeyPress::rightKey }, - { nsStringToJuce (UIKeyInputEscape), KeyPress::escapeKey }, - { nsStringToJuce (UIKeyInputPageUp), KeyPress::pageUpKey }, - { nsStringToJuce (UIKeyInputPageDown), KeyPress::pageDownKey } }; + std::map result + { + { nsStringToJuce (UIKeyInputUpArrow), KeyPress::upKey }, + { nsStringToJuce (UIKeyInputDownArrow), KeyPress::downKey }, + { nsStringToJuce (UIKeyInputLeftArrow), KeyPress::leftKey }, + { nsStringToJuce (UIKeyInputRightArrow), KeyPress::rightKey }, + { nsStringToJuce (UIKeyInputEscape), KeyPress::escapeKey }, + #if JUCE_HAS_IOS_HARDWARE_KEYBOARD_SUPPORT + // These symbols are available on iOS 8, but only declared in the headers for iOS 13.4+ + { nsStringToJuce (UIKeyInputPageUp), KeyPress::pageUpKey }, + { nsStringToJuce (UIKeyInputPageDown), KeyPress::pageDownKey }, + #endif + }; #if JUCE_HAS_IOS_HARDWARE_KEYBOARD_SUPPORT if (@available (iOS 13.4, *)) @@ -839,7 +843,6 @@ static std::optional getKeyCodeForSpecialCharacterString (StringRef charact return iter != map.cend() ? std::make_optional (iter->second) : std::nullopt; } -#if JUCE_HAS_IOS_HARDWARE_KEYBOARD_SUPPORT static int getKeyCodeForCharacters (StringRef unmodified) { return getKeyCodeForSpecialCharacterString (unmodified).value_or (unmodified[0]); @@ -850,6 +853,7 @@ static int getKeyCodeForCharacters (NSString* characters) return getKeyCodeForCharacters (nsStringToJuce (characters)); } +#if JUCE_HAS_IOS_HARDWARE_KEYBOARD_SUPPORT static void updateModifiers (const UIKeyModifierFlags flags) { const auto convert = [&flags] (UIKeyModifierFlags f, int result) { return (flags & f) != 0 ? result : 0; }; @@ -1920,10 +1924,12 @@ void UIViewComponentPeer::handleTouches (UIEvent* event, MouseEventFlags mouseEv if (event == nullptr) return; + #if JUCE_HAS_IOS_HARDWARE_KEYBOARD_SUPPORT if (@available (iOS 13.4, *)) { updateModifiers ([event modifierFlags]); } + #endif NSArray* touches = [[event touchesForView: view] allObjects];