Fixed build when using an older Xcode SDK

Fixes https://github.com/libsdl-org/SDL/issues/12048
This commit is contained in:
Sam Lantinga 2025-01-21 17:23:08 -08:00
parent cb3cc28809
commit 6f3d0b3cdb
2 changed files with 28 additions and 5 deletions

View File

@ -50,9 +50,7 @@ static id disconnectObserver = nil;
#include <objc/message.h> #include <objc/message.h>
/* remove compilation warnings for strict builds by defining these selectors, even though // Fix build errors when using an older SDK by defining these selectors
* they are only ever used indirectly through objc_msgSend
*/
@interface GCController (SDL) @interface GCController (SDL)
#if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 140500) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 140500) || (__MAC_OS_X_VERSION_MAX_ALLOWED >= 110300)) #if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 140500) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 140500) || (__MAC_OS_X_VERSION_MAX_ALLOWED >= 110300))
@property(class, nonatomic, readwrite) BOOL shouldMonitorBackgroundEvents; @property(class, nonatomic, readwrite) BOOL shouldMonitorBackgroundEvents;

View File

@ -28,6 +28,31 @@
#include "../../events/SDL_pen_c.h" #include "../../events/SDL_pen_c.h"
// Fix build errors when using an older SDK by defining these selectors
#if !defined(SDL_PLATFORM_TVOS)
@interface UITouch (SDL)
#if !(__IPHONE_OS_VERSION_MAX_ALLOWED >= 170500)
@property (nonatomic, readonly) CGFloat rollAngle;
#endif
@end
@interface UIHoverGestureRecognizer (SDL)
#if !(__IPHONE_OS_VERSION_MAX_ALLOWED >= 160100)
@property (nonatomic, readonly) CGFloat zOffset;
#endif
#if !(__IPHONE_OS_VERSION_MAX_ALLOWED >= 160400)
- (CGFloat) azimuthAngleInView:(UIView *) view;
@property (nonatomic, readonly) CGFloat altitudeAngle;
#endif
#if !(__IPHONE_OS_VERSION_MAX_ALLOWED >= 170500)
@property (nonatomic, readonly) CGFloat rollAngle;
#endif
@end
#endif // !SDL_PLATFORM_TVOS
static SDL_PenID apple_pencil_id = 0; static SDL_PenID apple_pencil_id = 0;
bool UIKit_InitPen(SDL_VideoDevice *_this) bool UIKit_InitPen(SDL_VideoDevice *_this)
@ -142,11 +167,11 @@ extern void UIKit_HandlePenHover(SDL_uikitview *view, UIHoverGestureRecognizer *
static void UIKit_HandlePenAxesFromUITouch(SDL_uikitview *view, UITouch *pencil) static void UIKit_HandlePenAxesFromUITouch(SDL_uikitview *view, UITouch *pencil)
{ {
float rollAngle = 0.0f; float rollAngle = 0.0f;
#if !defined(SDL_PLATFORM_TVOS) #if !defined(SDL_PLATFORM_TVOS)
if (@available(iOS 17.5, *)) { if (@available(iOS 17.5, *)) {
rollAngle = (float) [pencil rollAngle]; rollAngle = (float) [pencil rollAngle];
} }
#endif #endif
SDL_Window *window = [view getSDLWindow]; SDL_Window *window = [view getSDLWindow];
const CGPoint point = [pencil locationInView:view]; const CGPoint point = [pencil locationInView:view];