devicekit / DeviceKit

DeviceKit is a value-type replacement of UIDevice.
MIT License
4.4k stars 425 forks source link

Deprecated: `UIScreen.main` #358

Open henrikac opened 12 months ago

henrikac commented 12 months ago

I can see in the source code that this package is using UIScreen.main a lot. However, this was deprecated in iOS 16.

https://developer.apple.com/documentation/uikit/uiscreen/1617815-main

acosmicflamingo commented 7 months ago

I wonder how realistic it it would be to replace it with the recommended way of accessing a scene instance to get the screen:

let screen = UIApplication.shared.connectedScenes.first(
  where: { $0 is UIWindowScene }
) as? UIWindowScene

Because it's optional, I don't know of a clean replacement that is guaranteed to always return some screen object like what UIScreen.main does.