@@ -14,6 +14,7 @@ use std::{
1414} ;
1515
1616use objc2:: runtime:: AnyObject ;
17+ use once_cell:: sync:: Lazy ;
1718
1819use crate :: {
1920 dpi:: LogicalSize ,
@@ -1005,29 +1006,24 @@ impl NSOperatingSystemVersion {
10051006}
10061007
10071008pub fn os_capabilities ( ) -> OSCapabilities {
1008- lazy_static ! {
1009- static ref OS_CAPABILITIES : OSCapabilities = {
1010- let version: NSOperatingSystemVersion = unsafe {
1011- let process_info: id = msg_send![ class!( NSProcessInfo ) , processInfo] ;
1012- let atleast_ios_8: bool = msg_send![
1013- process_info,
1014- respondsToSelector: sel!( operatingSystemVersion)
1015- ] ;
1016- // tao requires atleast iOS 8 because no one has put the time into supporting earlier os versions.
1017- // Older iOS versions are increasingly difficult to test. For example, Xcode 11 does not support
1018- // debugging on devices with an iOS version of less than 8. Another example, in order to use an iOS
1019- // simulator older than iOS 8, you must download an older version of Xcode (<9), and at least Xcode 7
1020- // has been tested to not even run on macOS 10.15 - Xcode 8 might?
1021- //
1022- // The minimum required iOS version is likely to grow in the future.
1023- assert!(
1024- atleast_ios_8,
1025- "`tao` requires iOS version 8 or greater"
1026- ) ;
1027- msg_send![ process_info, operatingSystemVersion]
1028- } ;
1029- version. into( )
1030- } ;
1031- }
1009+ static OS_CAPABILITIES : Lazy < OSCapabilities > = Lazy :: new ( || {
1010+ let version: NSOperatingSystemVersion = unsafe {
1011+ let process_info: id = msg_send ! [ class!( NSProcessInfo ) , processInfo] ;
1012+ let atleast_ios_8: bool = msg_send ! [
1013+ process_info,
1014+ respondsToSelector: sel!( operatingSystemVersion)
1015+ ] ;
1016+ // tao requires atleast iOS 8 because no one has put the time into supporting earlier os versions.
1017+ // Older iOS versions are increasingly difficult to test. For example, Xcode 11 does not support
1018+ // debugging on devices with an iOS version of less than 8. Another example, in order to use an iOS
1019+ // simulator older than iOS 8, you must download an older version of Xcode (<9), and at least Xcode 7
1020+ // has been tested to not even run on macOS 10.15 - Xcode 8 might?
1021+ //
1022+ // The minimum required iOS version is likely to grow in the future.
1023+ assert ! ( atleast_ios_8, "`tao` requires iOS version 8 or greater" ) ;
1024+ msg_send ! [ process_info, operatingSystemVersion]
1025+ } ;
1026+ version. into ( )
1027+ } ) ;
10321028 OS_CAPABILITIES . clone ( )
10331029}
0 commit comments