iPhone Duo for iOS Developers: What Actually Changes in Your Swift Code
Apple announced the iPhone Duo today — its first foldable iPhone. A 5.4-inch outer display, a 7.6-inch inner display when you open it, ships with iOS 27.x. The marketing story is the hardware. The developer story is that a lot of assumptions baked into iPhone apps since 2007 just stopped being true. There is now more than one screen. The screen can change shape while your app is running. The safe…
Apple unveiled the iPhone Duo, its first foldable iPhone, featuring a 5.4-inch outer screen and a 7.6-inch inner screen upon opening. The announcement primarily focuses on hardware, but developers must adapt their Swift code to handle the new display capabilities. Here's a breakdown of the changes and what developers need to do to make their apps work seamlessly on the iPhone Duo.
Firstly, your app will still run even without changes, but it may not utilize the full screen effectively. Building against older SDKs will result in letterboxing or reduced app size, while using the iOS 27 SDK will allow your app to extend to the edge of the screen.
The most significant shift in your app's behavior is the removal of orientation-based layout decisions. Instead of relying on UIDevice.orientation or supportedInterfaceOrientations, use size classes to adapt your layout. In SwiftUI, use @Environment(\.horizontalSizeClass) and @Environment(\.verticalSizeClass) to create layouts for different screen configurations. In UIKit, override traitCollectionDidChange to reconfigure your layout based on the horizontalSizeClass.
Avoid using UIScreen.main, as it is ambiguous in a two-display device. Instead, query the displayScale from the trait collection or the window scene's screen property. Prefer using the scene's bounds for layout sizing or the environment.
Safe areas are now asymmetric, especially with the camera on one side. Handle each side independently when calculating usableWidth. For background artwork, use ignoresSafeArea to ensure it extends past the safe area, while interactive foreground content should stay inside the safe area.
Lastly, be aware of reserved regions, such as the hinge and under-display camera. Use GeometryReader in SwiftUI to detect and handle these regions, or reserveRegions in UIKit to avoid visual artifacts and ensure proper layout.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.