iPhone Duo Dev Hub RevDog
  1. Dev Hub
  2. Blog
  3. UIScreen.main.bounds

Developer notes

Is UIScreen.main.bounds valid on iPhone Duo?

Short answer: do not use it for layout. Apple's documentation marks UIScreen.main deprecated as of iOS 26, and Apple's iPhone Duo Tech Talk calls the main screen ambiguous on a device with two displays.

Published 19 November 2026Apple docs, release notes, Tech Talk 111461, TN3187Sources checked 19 November 2026

Our three-steps post has Apple's full replacement table. This post covers what that table leaves out: why the value misleads you on the Duo, what Apple says to read instead, and what an app with no scene delegate has to do first.

Paragraphs that start with Our reading are our interpretation, not Apple's words.

What Apple's documentation says

APIStatus in Apple's documentation
UIScreen.mainDeprecated in iOS 26.0 (also iPadOS, Mac Catalyst and tvOS 26.0). The deprecation note reads "Use screen instead." and links to UIWindowScene.screen. The longer message adds: "Use a UIScreen instance found through context instead (i.e, view.window.windowScene.screen), or for properties like UIScreen.scale with trait equivalents, use a traitCollection found through context."
UIWindowScene.screenAvailable since iOS 13. "The screen that displays the contents of the scene."
UIWindowScene.effectiveGeometryAvailable since iOS 16. "The current values for the window scene’s geometry in system space."
UITraitCollection.displayScaleAvailable since iOS 8. "The display scale of the trait collection."

The iOS & iPadOS 26 release notes record the change: "UIScreen.mainScreen has been changed from API_TO_BE_DEPRECATED to deprecated in iOS 26, tvOS 26, and visionOS 26." It still compiles. Xcode shows the deprecation warning only when your deployment target is iOS 26 or later.

Why it misleads on iPhone Duo

Apple's Tech Talk Prepare your app for iPhone Duo covers this in its "Avoid screen assumptions" chapter (3:57): "On a device with two displays, avoid referencing the main screen in your code. It's ambiguous and will be deprecated in a future release."

The talk speaks of a future deprecation. Apple's documentation, read on 19 November, already lists it as deprecated in iOS 26.0. Either way the advice is the same.

Our reading: if code asks "how big is the screen?" on a phone whose screen changes when it opens, the answer can be wrong as soon as the phone opens or closes. And on a device with an inner and an outer display, "the main screen" does not say which one you mean. Code that asks "how big is my view?" gets a fresh answer on every layout pass.

What Apple says to use instead

The same chapter of the Tech Talk goes on: "If possible, don't use screen references at all. Instead, use more local concepts like the environment, trait collection, or the scene's bounds. If you need access to the screen, access it dynamically from the window scene."

Our reading: together with the documentation's deprecation message, that gives an order of preference, from best to worst:

  1. The view you are laying out: view.bounds or superview.bounds, read during layout. In SwiftUI, the proposed size, GeometryReader or onGeometryChange.
  2. Traits and environment for class-level decisions: size classes and displayScale.
  3. The window or its scene: view.window?.bounds, or the screen from view.window?.windowScene?.screen, read when you need it rather than stored.
  4. Never UIScreen.main for anything that affects layout.

Apps without a scene delegate

In an app without a scene delegate, the window is usually built in the app delegate, and views are often sized from UIScreen.main.bounds in init(frame:). Apple's technote TN3187: Migrating to the UIKit scene-based life cycle sets a deadline for that pattern: "In the next major release following iOS 26, UIScene lifecycle will be required when building with the latest SDK; otherwise, your app won’t launch. While supporting multiple scenes is encouraged, only adoption of scene life-cycle is required."

Our reading: iOS 27 is that next major release, and the Duo's full-screen layout needs the iOS 27.1 SDK (see the three compatibility levels). An app that wants the Duo's inner display edge to edge therefore has to adopt the scene life cycle first. An app built with an SDK older than iOS 27 runs letterboxed on the inner display.

Then move manual frame code to the layout methods. Apple's documentation for UIView.layoutSubviews(): "Subclasses can override this method as needed to perform more precise layout of their subviews. … You can use your implementation to set the frame rectangles of your subviews directly." And for UIViewController.viewDidLayoutSubviews(): "When the bounds change for a view controller’s view, the view adjusts the positions of its subviews and then the system calls this method."

Size-change work: our replacement table also lists viewWillTransition(to:with:) for work that runs when the size changes. Our suggestion: keep frames in the layout methods, and use the transition callback only for one-off work such as saving a scroll position.

The fix in code

Read size during layout, not at creation

The card.frame line is the pattern the Tech Talk shows for foreground content (6:52).

// Before: size fixed once,
// from the device's screen
let card = CardView(frame:
    UIScreen.main.bounds)

// After: size follows the view,
// every time layout runs
override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    card.frame = view.bounds
        .inset(by: view.safeAreaInsets)
}

Create the window from a scene

This is the scene life cycle step from TN3187. You also need a scene configuration that names your delegate class: in Info.plist (UIApplicationSceneManifest), or returned from application(_:configurationForConnecting:options:).

final class SceneDelegate: UIResponder,
    UIWindowSceneDelegate {
    var window: UIWindow?

    func scene(_ scene: UIScene,
               willConnectTo session: UISceneSession,
               options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = scene as? UIWindowScene
        else { return }
        let window = UIWindow(windowScene: windowScene)
        window.rootViewController = RootViewController()
        window.makeKeyAndVisible()
        self.window = window
    }
}

Scale and screen, read where you are

// Before
let scale = UIScreen.main.scale

// After: the trait the Tech Talk
// sample switches to (9:25)
let scale = traitCollection.displayScale

// Need the screen itself? Read it
// now; don't store it
let screen =
    view.window?.windowScene?.screen

Find every use

grep -rn "UIScreen.main" \
  --include="*.swift" \
  --include="*.m" --include="*.mm" .

Our reading: the dot in the pattern matches any character, so it also finds Objective-C's [UIScreen mainScreen]. Sort the hits into three groups. Layout uses get the view-bounds fix. Scale uses get displayScale. Anything left over, such as brightness or screen capture, gets the scene's screen, read at the moment of use. Xcode warns only when your deployment target is iOS 26 or later, and not in targets where warnings are hidden; the grep finds every use regardless.

Checklist

  • No UIScreen.main in any layout path
  • Manual frames set in layoutSubviews or viewDidLayoutSubviews from the view's bounds
  • Scale read from traitCollection.displayScale (SwiftUI: @Environment(\.displayScale))
  • Windows created with UIWindow(windowScene:), with the app on the scene life cycle
  • No stored UIScreen. Read it from view.window?.windowScene?.screen when needed
  • Fold and unfold tested in the iPhone Duo Simulator in Xcode 27.1 (see our viewport simulator for the sizes)
Provenance: API status is from Apple's documentation pages for UIScreen.main, UIWindowScene.screen, UIWindowScene.effectiveGeometry, UITraitCollection.displayScale, layoutSubviews() and viewDidLayoutSubviews(), and from the iOS & iPadOS 26 release notes. Quotes are from Tech Talk 111461 and TN3187. All were read on 19 November 2026. The code samples are ours, built on the APIs those sources name. Apple has not reviewed this page.