UI/AppKit: Make project buildable on macOS < 15

When trying to build Ladybird on macOS 14.3, it fails with the error:

```

No visible @interface for 'NSToolbar' declares the selector
'setAllowsDisplayModeCustomization:' (clang arc_may_not_respond)

```

This is caused by macOS < 15 not having the @interface definition for
in NSToolbar for setAllowsUserCustomization:(BOOL).

By dynamically calling the method, we can avoid the error altogether.
This commit is contained in:
Junior Rantila 2025-10-23 21:36:21 +02:00 committed by Tim Flynn
parent 6c71960425
commit 8c8961171c

View File

@ -94,7 +94,9 @@ static NSString* const TOOLBAR_TAB_OVERVIEW_IDENTIFIER = @"ToolbarTabOverviewIde
[self.toolbar setDelegate:self];
[self.toolbar setDisplayMode:NSToolbarDisplayModeIconOnly];
if (@available(macOS 15, *)) {
[self.toolbar setAllowsDisplayModeCustomization:NO];
if ([self.toolbar respondsToSelector:@selector(setAllowsDisplayModeCustomization:)]) {
[self.toolbar performSelector:@selector(setAllowsDisplayModeCustomization:) withObject:nil];
}
}
[self.toolbar setAllowsUserCustomization:NO];
[self.toolbar setSizeMode:NSToolbarSizeModeRegular];