windows was deprecated in iOS 15.0: Use UIWindowScene.windows on a relevant window scene instead

Got this warning? Here’s how to fix it with a clean one guard. guard let scenes = UIApplication.shared.connectedScenes.first as? UIWindowScene, let rootViewController = scenes.keyWindow?.rootViewController else { return } // use rootViewController and scenes as needed or simplify it even further by doing this: guard let rootViewController = (UIApplication.shared.connectedScenes.first as? UIWindowScene)?.keyWindow?.rootViewController else { return } That’s it!

June 11, 2024 · 1 min · 56 words · Cisco