frewsxcv / rust-dark-light

Rust crate to detect if dark mode or light mode is enabled
https://crates.io/crates/dark-light
81 stars 15 forks source link

Does not build on macOS < 10.14 #14

Closed sourcebox closed 2 years ago

sourcebox commented 2 years ago

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.

frewsxcv commented 2 years ago

@sourcebox Is there a way to check macOS version from Rust without adding a dependency?

sourcebox commented 2 years ago

@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.

Be-ing commented 2 years ago

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.

sourcebox commented 2 years ago

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).

Be-ing commented 2 years ago

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.

sourcebox commented 2 years ago

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?

sourcebox commented 2 years ago

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.