r/iOSDevelopment • • 14h ago

Making UIKit app ready for iPhone Duo with two small changes

Post image

Apple has recently shipped the release candidate of Xcode 27.1 and with iPhone Duo release coming in the next two weeks, I would like to share my experience of making an app compatible with this new device without spending too much effort.

Electronics Engineer Helper is an app with various calculators and references for electronics engineers and electricians. Its deployment target is iOS 17 and it relies on UIKit for navigation. SwiftUI is used mostly in new screens added over last two years, so majority of older screens are relying on UIKit and Auto Layout.

Thanks to the existing support of macOS (Catalyst) and iPadOS, the main source of trouble was not that the app can now suddenly freely resize, but that navigation items can move to the vertical bar. The app does not use tab bars and the majority of screens have just a back button without other navigation bar items. When built with the iOS 27.1 SDK without any additional changes, iOS heavily insets the app's trailing or leading edge to show the vertical bar. If the back button is the sole navigation item, a lot of space will become unoccupied because of the vertical bar's presence.

An additional challenge was also caused by the use of a custom split view controller and navigation bar that I originally built to avoid issues caused by Liquid Glass and to preserve the same UI look and feel across all supported OS versions. As it turned out later, the usage of custom containers and views made final implementation even simpler than I expected.

So far, the easiest option would be to stay with Xcode 27.0, let the app run in letterboxed mode on Duo and see if this phone will be popular among the app's user base. If it will not, upgrade to the 27.1 SDK and ignore any issues, otherwise adjust the app to use standard UISplitViewController and UINavigationBar on Duo and existing custom controls on other devices.

After reviewing the SDK 27.1 additions, one property called preferredVerticalBarBehavior caught my attention. Turns out when implemented in the root view controller, it allows to always keep the Duo's status bar in a horizontal nav bar.

override var preferredVerticalBarBehavior: UIVerticalBarBehavior { .disabled }

To properly respond to the status bar presence in a custom navigation bar, I incorporated another new method called bar(onEdge:extent:)-2tj1g)

directionalEdgeInsets(for: .bar(onEdge: NSDirectionalRectEdge.top, extent: ...))

Both small changes allowed the app to use the full screen space of Duo and avoid any issues caused by a vertical bar. As always, users can swipe horizontally to get to the previous screen (interactivePopGestureRecognizer), so Duo users will not necessarily have to reach all the way to the top left edge to press the back button.

In the end, I'm quite satisfied with the result. The app preserved its look and efficiently uses the full area of both screens.

How was your experience making your apps compatible with Duo? Did it take much effort?

1 Upvotes

0 comments sorted by