Closed sourcebox closed 2 years ago
@sourcebox Is there a way to check macOS version from Rust without adding a dependency?
@sourcebox Is there a way to check macOS version from Rust without adding a dependency?
I'm not aware of a direct method how to get this. Maybe some environment variable. But please keep in mind that the OS version where the app is built can be different from the one on which it is run afterwards. E.g. I use GitHub actions with an 10.15 image to finally build my apps for deployment, but they can also run on earlier OS versions.
If you want to build for macOS versions before dark mode was introduced then I think it would make sense to put usage of this crate in your application behind a Cargo feature. Though I don't know why you'd go through this trouble instead of building for macOS 10.14.
I'm not using this crate directly but egui
which has it as a dependency. So it has to be feature-gated there if there is no way to solve it here at the source (which was the original intention).
Technically it could be possible to make this crate build for macOS < 10.14, but it would be almost pointless because the crate wouldn't do anything.
BTW: it would be great if you could add some info in the README about the system requirements for this crate on all platforms. E.g. does this build also on Ubuntu 18.04 (required for AppImages) or Windows 7?
Technically it could be possible to make this crate build for macOS < 10.14, but it would be almost pointless because the crate wouldn't do anything.
Of course this would make sense because it would lead to behaving the resulting app graceful. Below 10.14, just nothing would happen, starting with 10.14 automatic theme switching would be possible. The most important thing is that the app just would build and run on older systems.
Some commits ago, the detection method on macOS was changed to not using shell commands. This unfortunately leads to the situation that the crate can't be build below macOS 10.14 in which the dark mode was introduced. As a consequence, the system requirements for all apps using this crate are also raised to macOS 10.14, otherwise a linker error is triggered and the build fails.
Please provide a graceful way to support older macOS versions. Maybe the old way of detection could be offered again as an alternative which is feature gated.