Created
July 28, 2021 06:05
-
-
Save dezinezync/1ff79607462de44011a9fb1bbf8c7e73 to your computer and use it in GitHub Desktop.
Xcode 13 Beta 3 and above: Workaround for UIApplication usage in SPM packages
This file contains hidden or 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
private func someFunc() -> Bool { | |
guard let aClass = NSClassFromString("UIApplication") else { | |
return false | |
} | |
// fetch properties as necessary. | |
let layoutDirection = UIUserInterfaceLayoutDirection(rawValue: aClass.value(forKeyPath: "sharedApplication.userInterfaceLayoutDirection") as! Int) | |
// use runtime inspection to determine return value type. | |
let state = UIApplication.State(rawValue: aClass.value(forKeyPath: "sharedApplication.applicationState") as! Int) | |
// use the values as necessary. | |
return state == .active || layoutDirection == .rightToLeft | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment