forked from pointfreeco/swift-perception
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from monzo/oliver/revert-ios-17-0-1-check-and-f…
…orcePerceptionChecking Fallback to Perception on iOS 17 beta builds
- Loading branch information
Showing
4 changed files
with
34 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Foundation | ||
|
||
// NB: This boolean is used to work around a crash experienced by beta users of Observation when | ||
// `Observable` was still a marker protocol and we attempt to dynamically cast to | ||
// `any Observable`. | ||
let isObservationBeta: Bool = { | ||
#if os(iOS) || os(tvOS) || os(watchOS) | ||
let os = ProcessInfo.processInfo.operatingSystemVersion | ||
#if os(iOS) || os(tvOS) | ||
if (os.majorVersion, os.minorVersion, os.patchVersion) != (17, 0, 0) { | ||
return false | ||
} | ||
#elseif os(watchOS) | ||
if (os.majorVersion, os.minorVersion, os.patchVersion) != (10, 0, 0) { | ||
return false | ||
} | ||
#endif | ||
var size = 0 | ||
sysctlbyname("kern.osversion", nil, &size, nil, 0) | ||
var version = [CChar](repeating: 0, count: size) | ||
let ret = sysctlbyname("kern.osversion", &version, &size, nil, 0) | ||
// NB: Beta builds end with a lowercase character (_e.g._, '21A5277j') | ||
return ret == 0 ? String(cString: version).last?.isLowercase == true : false | ||
#else | ||
return false | ||
#endif | ||
}() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters