-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fallback to Perception on iOS 17 beta builds (#66)
* revert perception checking iOS 17.0.1 and add a boolean to allow consumers to force perception checking * Update PerceptionChecking.swift * Update PerceptionRegistrar.swift * Remove configuration and use a runtime check * Remove unused watchkit import * Documentation * sp * cleanup * Update Sources/Perception/Internal/BetaChecking.swift * Update BetaChecking.swift * fix * check return value before creating cString --------- Co-authored-by: Stephen Celis <[email protected]>
- Loading branch information
1 parent
c78c53e
commit a7d774a
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