From 22b4e80e5bc8890bce9f8a826f64fa89ff0597cd Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Tue, 14 Jul 2026 14:47:52 +0000 Subject: [PATCH 4/5] Cocoa: Guard -loadNibNamed:owner:topLevelObjects: for the 10.6 SDK -[NSBundle loadNibNamed:owner:topLevelObjects:] was added in the 10.8 SDK. On 10.6/10.7 NSBundle does not implement it, so building against the 10.6 SDK only produces a "may not respond to" warning (NSBundle is statically typed, so GCC still compiles the call), but running the result on real 10.6/10.7 throws NSInvalidArgumentException the same way the already-fixed -setRestorable: call did. This path only triggers when a custom MainMenu.nib is bundled with the menubar hint enabled, which is why it wasn't caught by the earlier smoke test. Fall back to the legacy +[NSBundle loadNibNamed:owner:] class method, which has existed since 10.0; it does not populate topLevelObjects, but that field (_glfw.ns.nibObjects) is otherwise unused so this is harmless. --- src/cocoa_init.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index d5784e42..14c5fd72 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -455,9 +455,18 @@ static GLFWbool initializeTIS(void) if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"]) { + // NOTE: -loadNibNamed:owner:topLevelObjects: was added in the + // 10.8 SDK; Mac OS X 10.6/10.7 only have the two-arg + // -loadNibNamed:owner:, which does not populate + // topLevelObjects (harmless, as nibObjects is otherwise + // unused) +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 [[NSBundle mainBundle] loadNibNamed:@"MainMenu" owner:NSApp topLevelObjects:&_glfw.ns.nibObjects]; +#else + [NSBundle loadNibNamed:@"MainMenu" owner:NSApp]; +#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ } else createMenuBar(); -- 2.43.0