Blog

Making a React Native app ready for iPhone Duo

Getting BeerXchange ready for iPhone Duo took one Xcode 27.1 build, five small layout fixes and a switch to the system tab bar so iOS can place the tabs in the Duo’s side column. What the Duo changes, the fixes with code, and a test checklist.

Chris Sweigard

What changes on iPhone Duo

The Duo breaks three assumptions most React Native layouts quietly make: one screen size, a camera at the top centre, and equal insets on both sides.

  • Two postures, one running app. Closed, the outer screen measured 466 × 678 points in the simulator; opened, 951 × 669. The app is resized live as the device folds, so nothing measured at launch stays true.
  • The camera sits in a corner. The status bar and pinhole camera run down the right edge, so the safe-area insets were top 0, right 84, bottom 34, left 0. Most iPhones put their inset on top.
  • Insets are asymmetric. Apple warns that layout maths assuming left equals right gives the wrong size on Duo.
  • The SDK you build with decides how much screen you get. Apps built with older Xcode versions do not extend beneath the status bar and camera, so build with Xcode 27.1.

React Native has no fold API, and none of the new iOS 27.1 reserved-region APIs have JavaScript bindings yet. In practice you treat the Duo as a window that changes size and has an inset on one side.

Before and after

All screenshots are from BeerXchange on the iPhone Duo simulator (iOS 27.1, Xcode 27.1).

BeerXchange Collection screen on the closed iPhone Duo, before the fix
Before
BeerXchange Collection screen on the closed iPhone Duo, after the fix
After
Collection, Duo closed. Before, the tab area was 298 points wide instead of 382 and prices were cut off. After, it fills the space beside the camera.
BeerXchange Profile screen on the closed iPhone Duo, before the fix
Before
BeerXchange Profile screen on the closed iPhone Duo, after the fix
After
Profile, Duo closed. Before, every card was cut off on the left, starting mid-word. After, the banner, tabs and cards sit inside the safe area.
BeerXchange Profile screen on the open iPhone Duo, before the fix
Before
BeerXchange Profile screen on the open iPhone Duo, after the fix
After
Profile, Duo open. Before, the header logo was clipped at the top and card text started mid-word. After, the logo fits the 32-point landscape header and the content reflows to 867 points.

The fixes

Six changes did it on React Native 0.87.1: five in JavaScript, plus moving iPhone to the system tab bar.

1. Build with Xcode 27.1

No code changes were needed for the build itself: the app and its pods compiled cleanly against the iOS 27.1 SDK. The Duo simulator needs the iOS 27.1 runtime, so install it from Xcode › Settings › Components.

2. Read the window size at render time

Anything measured once at startup is wrong after the Duo folds. Swap module-level Dimensions.get for the useWindowDimensions hook.

// Before: captured once, stale after a resize
const { width } = Dimensions.get('window')

// After: re-read on every render
const isTablet = useWindowDimensions().width >= 600

Watch for libraries that do the same internally. The react-native-elements Tile defaults its width to the window width, which pushed our Profile screen 42 points past the camera inset. Pass the width you actually have, one side at a time:

const { width } = useWindowDimensions()
const insets = useSafeAreaInsets()

<Tile featured width={width - insets.left - insets.right} … />

3. Don’t nest provider-based SafeAreaViews

The SafeAreaView from react-native-safe-area-context pads by the nearest provider’s full insets, not by how much the view actually overlaps the camera. Nest one inside another and the 84-point camera inset is applied twice; our Collection tabs shrank from 382 to 298 points. Use one safe-area container per screen (or set edges), and use plain views inside it.

4. Remount native pagers when their width changes

Top tabs (react-native-tab-view on react-native-pager-view) did not reliably re-lay out their pages after a resize, or when insets settled after the first layout. A small wrapper measures its container and remounts the navigator on a width change, reopening the tab that was showing:

ResizeSafeTopTabs.tsx
const ResizeSafeTopTabs = ({ navigator: Navigator, initialRouteName, children, ...props }) => {
  const [width, setWidth] = useState<number | null>(null)
  const focused = useRef(initialRouteName)

  return (
    <View
      style={{ flex: 1, alignSelf: 'stretch' }}
      onLayout={e => setWidth(Math.round(e.nativeEvent.layout.width))}
    >
      {width != null && (
        <Navigator
          key={width}
          initialRouteName={focused.current}
          screenListeners={({ route }) => ({ focus: () => { focused.current = route.name } })}
          {...props}
        >
          {children}
        </Navigator>
      )}
    </View>
  )
}

alignSelf: 'stretch' matters too: in a parent with alignItems: 'center', tab pages set an explicit width and would otherwise size the container to the full window.

5. Fit header content to the bar you get

React Navigation’s stack header is 44 points tall on iPhone portrait but 32 points in landscape, and the open Duo counts as landscape. Our 40-point logo overflowed the top of the screen. Size header items from the window shape, and take keyboard offsets from the measured header height rather than a hard-coded number:

const { width, height } = useWindowDimensions()
const logoSize = width > height && !Platform.isPad ? 28 : 40

<KeyboardAvoidingView behavior="padding" keyboardVerticalOffset={useHeaderHeight()}>

6. Use the system tab bar so iOS can move it into the side column

On the closed Duo, iOS moves the status bar, toolbar buttons and tab bar into one column beside the camera, but only for bars that come from UITabBarController. A tab bar drawn in JavaScript stays at the bottom of the screen. React Navigation’s native bottom tabs use UITabBarController, so switching to them on iPhone moved our tabs into the side column with no layout code of our own.

BeerXchange Collection screen on the closed iPhone Duo, before the fix
Before
BeerXchange Collection screen on the closed iPhone Duo, after the fix
After
Tabs, Duo closed. Before, the JavaScript tab bar sat along the bottom and took height from the list. After, the system tab bar sits in the side column below the camera, and the list runs the full height of the screen.
BeerXchange Collection screen on the open iPhone Duo, with the tabs in the side column
Tabs, Duo open. The open Duo counts as landscape, so the tabs stay in the side column there too.
routes.tsx
import { createNativeBottomTabNavigator } from '@react-navigation/bottom-tabs/unstable'

const NativeTabs = createNativeBottomTabNavigator()

// iPhone (including Duo): system tab bar. iPad and Android: the existing JS tab bar.
if (Platform.OS === 'ios' && !Platform.isPad) {
  return (
    <NativeTabs.Navigator>
      <NativeTabs.Screen
        name="Collection"
        component={Collection}
        options={{ headerShown: false, tabBarIcon: { type: 'sfSymbol', name: 'list.bullet' } }}
      />
      {/* …one screen per tab */}
    </NativeTabs.Navigator>
  )
}

What it took:

  • Upgrades. react-native-screens 4.30.0 (the navigator’s minimum) and React Navigation 7.21, then pod install and a native rebuild.
  • SF Symbols for icons. Native tabs don’t render React components as icons, so each tab names an SF Symbol.
  • A one-line native fix. Launched while the Duo was open, the side column came up empty. react-native-screens PR #4990 fixes this by sizing the tab bar controller’s view before attaching it. We applied it to 4.30.0 with patch-package until a release includes it.
  • Pad each tab once by the window insets. Under the native tab bar, each screen’s own safe-area measurement changed mid-transition, so lists re-laid out and dropped taps. We wrap every tab screen in a view padded by the window’s left and right insets, and report zero side insets to everything inside it.
  • Keep the JS tab bar on iPad. On iPad, UIKit puts the system tab bar at the top, where it covered our JS stack headers, and there is no API to put it back at the bottom. Android also keeps the JS tab bar.
  • No control over order within the column. iOS keeps the tabs at the bottom of the side column, as on a regular iPhone, and offers no API to start them at the top.

Test checklist

Test every screen in each of these, and fold or rotate while the app is open, not only at launch.

DeviceSize (points)What to look for
iPhone Duo, closed466 × 678, 84 pt right insetTabs in the side column below the camera; nothing under it; no clipping on the left
iPhone Duo, open951 × 669Side-column tabs appear after a cold launch while open; lists reflow; header items fit a 32 pt bar
Regular iPhone (we used iPhone 18 Pro)402 × 874No doubled top padding under the header; keyboard clears text inputs
iPad, portrait and landscape834 × 1210 / 1210 × 834Tab pages reflow after rotation

Two practical notes. Installing the iOS 27.1 runtime left the simulator service unresponsive for several minutes, stalling a build in progress. And logging useSafeAreaInsets() alongside a container’s onLayout found the doubled inset in minutes, after screenshots alone had pointed us at the wrong cause.

Sources

Measurements and screenshots are from our own tests of BeerXchange on the Xcode 27.1 simulators.

Have an app that needs the same care?

I do this kind of work on client codebases: find what breaks, fix it at the source, and leave notes your team can follow.