iOS 26 Beta 3 `safeAreaInsets`

I noticed that trying to access safeAreaInsets from the active window causes an infinite run loop. This issue appeared after updating to Beta 3. Here’s an example of the code:

extension UIDevice {
    var safeAreaInsets: UIEdgeInsets {
        guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
              let window = windowScene.windows.first(where: { $0.isKeyWindow }) else {
            return .zero
        }

        return window.safeAreaInsets
    }
}

The return doesn’t happen because it ends up in some kind of recursion.

Answered by LazloGogoLaka in 852786022

I moved the UIDevice.current.safeAreaInsets value into a constant to avoid using it directly in multiple places.

Before:

.padding(.bottom, UIDevice.current.safeAreaInsets.bottom)

After:

enum Constant {
    static let safeAreaInsets = UIDevice.current.safeAreaInsets
}

.padding(.bottom, Constant.safeAreaInsets.bottom)

Beta 3 of what? iOS, iPadOS, Xcode?

I can't reproduce this on Xcode 26 beta 3 with iOS 26 beta 3, or Xcode 26 beta 3 with iOS 18.5.

Do we need more code than you've given, maybe?

The issue is with iOS 26 on a project built with Xcode 16.4. I’m encountering a recursion loop specifically when trying to use the safeArea value — for example, for bottom padding .padding(.bottom, max(16, UIDevice.current.safeAreaInsets.bottom))

However, when I move a simplified version of the view into a test project, the problem disappears. So I’ll continue investigating what exactly is triggering the recursion in this specific case. I’ll also try building the project with xCode 26. It’s weird because everything was working fine on iOS26 Beta 2, and these weird freezes only started after updating the phone to Beta 3. Thanks for getting back to me!

@LazloGogoLaka , it also happens to me. Have you been able to find a solution to this?

still happening on Beta 4. For the time being I hard-coded some Safe Area values to be used on iOS 26. Top: 59px, Bottom: 84px.

Accepted Answer

I moved the UIDevice.current.safeAreaInsets value into a constant to avoid using it directly in multiple places.

Before:

.padding(.bottom, UIDevice.current.safeAreaInsets.bottom)

After:

enum Constant {
    static let safeAreaInsets = UIDevice.current.safeAreaInsets
}

.padding(.bottom, Constant.safeAreaInsets.bottom)
iOS 26 Beta 3 `safeAreaInsets`
 
 
Q