diff --git a/modules/juce_audio_processors/format_types/juce_AU_Shared.h b/modules/juce_audio_processors/format_types/juce_AU_Shared.h index ba2942c15d..1e136f6812 100644 --- a/modules/juce_audio_processors/format_types/juce_AU_Shared.h +++ b/modules/juce_audio_processors/format_types/juce_AU_Shared.h @@ -40,8 +40,8 @@ #endif -#if (JUCE_IOS && defined (__IPHONE_15_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_15_0) \ - || (JUCE_MAC && defined (MAC_OS_VERSION_12_0) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_12_0) +#if (JUCE_IOS && JUCE_IOS_API_VERSION_CAN_BE_BUILT (15, 0)) \ + || (JUCE_MAC && JUCE_MAC_API_VERSION_CAN_BE_BUILT (12, 0)) #define JUCE_APPLE_MIDI_EVENT_LIST_SUPPORTED 1 #else #define JUCE_APPLE_MIDI_EVENT_LIST_SUPPORTED 0 diff --git a/modules/juce_core/native/juce_ObjCHelpers_mac.h b/modules/juce_core/native/juce_ObjCHelpers_mac.h index f533412b37..1722b1fa97 100644 --- a/modules/juce_core/native/juce_ObjCHelpers_mac.h +++ b/modules/juce_core/native/juce_ObjCHelpers_mac.h @@ -564,6 +564,14 @@ private: Class klass = nullptr; }; +// Expands to true if the API of the specified version is available at build time, false otherwise +#define JUCE_MAC_API_VERSION_CAN_BE_BUILT(major, minor) \ + major * 10'000 + minor * 100 <= MAC_OS_X_VERSION_MAX_ALLOWED + +// Expands to true if the API of the specified version is available at build time, false otherwise +#define JUCE_IOS_API_VERSION_CAN_BE_BUILT(major, minor) \ + major * 10'000 + minor * 100 <= __IPHONE_OS_VERSION_MAX_ALLOWED + #if JUCE_IOS // Defines a function that will check the requested version both at diff --git a/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm b/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm index 0f5221c913..fa59bc9b62 100644 --- a/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm +++ b/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm @@ -865,7 +865,7 @@ static std::optional getKeyCodeForSpecialCharacterString (StringRef charact { nsStringToJuce (UIKeyInputF12), KeyPress::F12Key } }); } - #if defined (__IPHONE_15_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_15_0 + #if JUCE_IOS_API_VERSION_CAN_BE_BUILT (15, 0) if (@available (iOS 15.0, *)) { result.insert ({ { nsStringToJuce (UIKeyInputDelete), KeyPress::deleteKey } }); @@ -1028,7 +1028,7 @@ static void postTraitChangeNotification (UITraitCollection* previousTraitCollect object: nil]; } -#if ! defined (__IPHONE_17_0) || __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_17_0 +#if JUCE_IOS_API_VERSION_CAN_BE_BUILT (17, 0) - (void) traitCollectionDidChange: (UITraitCollection*) previousTraitCollection { [super traitCollectionDidChange: previousTraitCollection]; @@ -1683,7 +1683,7 @@ Point juce_lastMousePos; struct ChangeRegistrationTrait { - #if defined (__IPHONE_17_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_17_0 + #if JUCE_IOS_API_VERSION_CAN_BE_BUILT (17, 0) API_AVAILABLE (ios (17)) static void newFn (UIView* view) { @@ -2222,7 +2222,7 @@ void Desktop::setKioskComponent (Component* kioskModeComp, bool enableOrDisable, void Desktop::allowedOrientationsChanged() { - #if defined (__IPHONE_16_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_16_0 + #if JUCE_IOS_API_VERSION_CAN_BE_BUILT (16, 0) if (@available (iOS 16.0, *)) { UIApplication* sharedApplication = [UIApplication sharedApplication]; diff --git a/modules/juce_gui_basics/native/juce_Windowing_ios.mm b/modules/juce_gui_basics/native/juce_Windowing_ios.mm index 6b11be9d91..2cb7ef66a8 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_ios.mm +++ b/modules/juce_gui_basics/native/juce_Windowing_ios.mm @@ -170,7 +170,7 @@ namespace juce struct BadgeUpdateTrait { - #if defined (__IPHONE_16_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_16_0 + #if JUCE_IOS_API_VERSION_CAN_BE_BUILT (16, 0) API_AVAILABLE (ios (16)) static void newFn (UIApplication*) { diff --git a/modules/juce_gui_basics/native/juce_Windowing_mac.mm b/modules/juce_gui_basics/native/juce_Windowing_mac.mm index 5cc63ce9aa..85c0eef6f2 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_mac.mm +++ b/modules/juce_gui_basics/native/juce_Windowing_mac.mm @@ -453,7 +453,7 @@ static Displays::Display getDisplayFromScreen (NSScreen* s, CGFloat& mainScreenB NSSize dpi = [[[s deviceDescription] objectForKey: NSDeviceResolution] sizeValue]; d.dpi = (dpi.width + dpi.height) / 2.0; - #if defined (MAC_OS_VERSION_12_0) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_12_0 + #if JUCE_MAC_API_VERSION_CAN_BE_BUILT (12, 0) if (@available (macOS 12.0, *)) { const auto safeInsets = [s safeAreaInsets]; diff --git a/modules/juce_gui_extra/native/juce_AppleRemote_mac.mm b/modules/juce_gui_extra/native/juce_AppleRemote_mac.mm index e52fbc6e3a..0b2f5493d7 100644 --- a/modules/juce_gui_extra/native/juce_AppleRemote_mac.mm +++ b/modules/juce_gui_extra/native/juce_AppleRemote_mac.mm @@ -58,7 +58,7 @@ namespace const auto defaultPort = [] { - #if defined (MAC_OS_VERSION_12_0) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_12_0 + #if JUCE_MAC_API_VERSION_CAN_BE_BUILT (12, 0) if (@available (macOS 12.0, *)) return kIOMainPortDefault; #endif diff --git a/modules/juce_video/native/juce_CameraDevice_ios.h b/modules/juce_video/native/juce_CameraDevice_ios.h index 54162e9b71..395385fa70 100644 --- a/modules/juce_video/native/juce_CameraDevice_ios.h +++ b/modules/juce_video/native/juce_CameraDevice_ios.h @@ -47,7 +47,7 @@ struct CameraDevice::Pimpl struct PreviewLayerAngleTrait { - #if defined (__IPHONE_17_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_17_0 + #if JUCE_IOS_API_VERSION_CAN_BE_BUILT (17, 0) API_AVAILABLE (ios (17)) static void newFn (AVCaptureDevice* device, AVCaptureVideoPreviewLayer* previewLayer, AVCaptureConnection* outputConnection) { @@ -66,7 +66,7 @@ struct CameraDevice::Pimpl struct CaptureLayerAngleTrait { - #if defined (__IPHONE_17_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_17_0 + #if JUCE_IOS_API_VERSION_CAN_BE_BUILT (17, 0) API_AVAILABLE (ios (17)) static void newFn (AVCaptureDevice* device, AVCaptureVideoPreviewLayer* previewLayer, AVCaptureConnection* outputConnection) { @@ -1224,7 +1224,7 @@ struct CameraDevice::ViewerComponent : public UIViewComponent struct AddObserverTrait { - #if defined (__IPHONE_17_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_17_0 + #if JUCE_IOS_API_VERSION_CAN_BE_BUILT (17, 0) API_AVAILABLE (ios (17)) static void newFn (ViewerComponent* self) {