ladybird
ladybird copied to clipboard
Support build on macOS Monterey (v12)
Building d29797f118 on macOS Monterey 12.7.6 fails with
/Users/bro/Documents/repositories/ladybird/Ladybird/AppKit/UI/SearchPanel.mm:66:36: error: use of undeclared identifier 'NSBezelStyleAccessoryBarAction'
66 | [search_done setBezelStyle:NSBezelStyleAccessoryBarAction];
| ^
NSBezelStyleAccessoryBarAction got introduced with macOS v14. AFAICT this is the only constant which prevents a successful build for earlier versions.
Currently I use this hack:
- [search_done setBezelStyle:NSBezelStyleAccessoryBarAction];
-
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ [search_done setBezelStyle:NSBezelStyleRoundRect];
+#pragma clang diagnostic pop
Looks like there's an official way to run different code on different versions of macOS. https://developer.apple.com/documentation/xcode/running-code-on-a-specific-version#Require-a-minimum-operating-system-version-for-a-feature
As far as I can tell, Apple still supports Monterey, so it seems reasonable to me for us to do so too if you feel like putting a PR together. (Or someone else does.)
Note that Apple's @available checks are runtime checks and generally still assume that you're building with the latest SDK/Xcode version, even when back-deploying to some older macOS version (which is generally encouraged).
To support building with an older SDK, we would have to cond-compile the constant out, e.g. using the __MAC_OS_X_VERSION_MAX_ALLOWED macro: https://stackoverflow.com/a/78050635
NSBezelStyleAccessoryBarAction is actually an interesting case, the API seems to have been added in the macOS 14 SDK, but does not require an available check (as other APIs like NSBezelStyleBadge, for example):
This can happen if the API existed as a private API before being added to the public SDK, so NSBezelStyleAccessoryBarAction might be present in macOS 12's runtime frameworks (AppKit in this case) and happily back-deploy to that macOS version, but still require the macOS 14 SDK to compile.