From 9807e76a25ba8ce85b3af165f2ebb39f4e00a7a5 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Sun, 6 Sep 2026 04:24:19 +0000 Subject: [PATCH] cocoa: mark WindowListener's window ivar unretained ARC requires an explicitly declared ivar behind an 'assign' object property to be __unsafe_unretained; the Xcode build stopped on it. RARCH_UNSAFE_UNRETAINED in cocoa_defines.h spells the qualifier under ARC and nothing under MRC, so the declaration - which the fragile 32-bit runtime needs written out - reads the same for both. --- libretro-common/include/defines/cocoa_defines.h | 5 +++++ ui/drivers/cocoa/apple_platform.h | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libretro-common/include/defines/cocoa_defines.h b/libretro-common/include/defines/cocoa_defines.h index c37410fc6b..0be6102bb6 100644 --- a/libretro-common/include/defines/cocoa_defines.h +++ b/libretro-common/include/defines/cocoa_defines.h @@ -173,6 +173,10 @@ #endif #if __has_feature(objc_arc) +/* Ownership qualifier for an ivar that backs an 'assign' object + * property: ARC requires the ivar to say it does not retain, and no + * other compiler knows the word. */ +#define RARCH_UNSAFE_UNRETAINED __unsafe_unretained #define RARCH_RETAIN(x) (x) #define RARCH_RELEASE(x) ((void)0) #define RARCH_AUTORELEASE(x) ((void)0) @@ -185,6 +189,7 @@ #define RARCH_AUTORELEASEPOOL_BEGIN @autoreleasepool { #define RARCH_AUTORELEASEPOOL_END } #else +#define RARCH_UNSAFE_UNRETAINED #define RARCH_RETAIN(x) [(x) retain] #define RARCH_RELEASE(x) [(x) release] #define RARCH_AUTORELEASE(x) [(x) autorelease] diff --git a/ui/drivers/cocoa/apple_platform.h b/ui/drivers/cocoa/apple_platform.h index 1e6ed0b20f..4cbabf7466 100644 --- a/ui/drivers/cocoa/apple_platform.h +++ b/ui/drivers/cocoa/apple_platform.h @@ -131,8 +131,9 @@ UINavigationControllerDelegate> { @interface WindowListener : NSResponder RARCH_PROTO_NSWINDOWDELEGATE { /* Declared, not synthesized: the fragile 32-bit runtime GCC 4.0 - * targets cannot add ivars for a property on its own. */ - NSWindow *_window; + * targets cannot add ivars for a property on its own. Unretained, + * as the assign property it backs requires under ARC. */ + RARCH_UNSAFE_UNRETAINED NSWindow *_window; } /* assign (not retain) - WindowListener is a delegate; the window owns it, not vice versa */ @property (nonatomic, assign) NSWindow *window;