Hi. In my project, I use the following property to access the safe area via UIApplication:
UIApplication
.shared
.connectedScenes
.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }
.first { $0.isKeyWindow }?.safeAreaInsets
However, in Xcode 26 and iOS 26, this no longer works, and in some cases the app crashes. Views that rely on this property stop behaving as expected. For example, if it’s a sheet, it does not appear.
The same app built with Xcode 16 and distributed via TestFlight runs on iOS 26 without any issues.
What is the correct and safe way to obtain safeAreaInsets outside of a View now?