Sanniv Khare 7 min read

react-native-screens 4.31 ships Package.swift: what changes

react-native-screens 4.31 ships Package.swift: what changes

react-native-screens 4.31.0, published to npm on 4 December 2026, is the first release on the 4.x line with a Package.swift. If your React Native app has moved its iOS side to Swift Package Manager, screens can now come in as a package instead of a pod. Two things to know before you switch: the package only resolves inside React Native’s own SwiftPM layout (you cannot add the GitHub URL in Xcode), and the RNS_GAMMA_ENABLED switch is read from the environment of whatever process resolves the package graph. The CocoaPods path is untouched: RNScreens.podspec is byte for byte the same as in 4.30.1.

This post is a source diff: we ran npm pack on react-native-screens 4.30.1 and 4.31.0 and compared the two packages file by file. At the time of writing the project’s GitHub releases page has no 4.31.0 entry yet; SwiftPM support first appeared on the 5.0 alpha line (5.0.0-alpha.3, PR #4593) and header minimization in 5.0.0-alpha.4 (PR #4703).

Why we did this: screens sits under the navigation of every React Native app we ship, from client banking apps to our TV apps, and we have been measuring the SwiftPM path since React Native 0.88 on SwiftPM vs CocoaPods and the CLI 21.1 init that defaults to SwiftPM. A core library gaining a manifest changes what a SwiftPM migration needs.

What the package diff shows

Summary of diff -rq between react-native-screens 4.30.1 and 4.31.0

Our summary of diff -rq on the two unpacked packages: 42 changed files under ios/, 21 changed and 2 new under android/, plus the new SwiftPM files.

Area 4.30.1 4.31.0
Package.swift none swift-tools-version 6.0, product RNScreens, platforms: [.iOS(.v15)]
spm/include none 77 forwarding headers
spm/include-gamma none 149 forwarding headers
package.json no SwiftPM key "swiftpmConfig": { "name": "RNScreens" }, spm/ and Package.swift added to files
react-native.config.js iOS config only spm: { name: 'RNScreens' }
RNScreens.podspec iOS 15.1, tvOS 15.1, visionOS 1.0 unchanged
ios/RNSEnums.h new RNSHeaderMinimizationBehavior, RNSScreenSheetBackgroundEffect, RNSTabsScreenAnimation
android/build.gradle Kotlin 1.8.0, AGP 8.2.1, Spotless 6.25.0 Kotlin 2.3.21, AGP 9.2.1, Spotless 8.11.0

The Package.swift, read closely

The trimmed Package.swift from react-native-screens 4.31.0

Three choices in the manifest decide how you can use it.

It depends on local paths, not on a React Native package URL

The two dependencies are .package(name: "ReactNative", path: "../../../../xcframeworks") and .package(name: "React-GeneratedCode", path: "../../../ios"). The comment above them says these resolve from the autolinker symlink at <app>/ios/build/generated/autolinking/libs/RNScreens, the layout npx react-native spm scaffold creates, so ../../../../xcframeworks lands on <app>/ios/build/xcframeworks. The comment also says a self-contained package is blocked until React Native publishes a remote SwiftPM package.

In practice: add screens through React Native’s SwiftPM autolinking (the swiftpmConfig and spm keys above are what it reads). Pointing Xcode’s “Add Package Dependencies” at the GitHub repository will not resolve, because those relative paths lead nowhere outside an app’s ios/build folder.

RNS_GAMMA_ENABLED moves from pod install to package resolution

let gammaProjectEnabled = Context.environment["RNS_GAMMA_ENABLED"] == "1"

The podspec reads the same variable (ENV['RNS_GAMMA_ENABLED'] == '1') during pod install. In Package.swift it is read whenever the package graph is resolved, and it picks a lot: which sources compile (ios/gamma or ios/stubs), which header folder is public (spm/include-gamma or spm/include), the extra header search paths and the RNS_GAMMA_ENABLED=1 define.

The manifest’s own comment names the processes that need it: xcodebuild and react-native run-ios. If you use the gamma components (the new stack, split and form-sheet hosts under ios/gamma), set the variable everywhere the package resolves: your terminal, your CI job, and Xcode itself when you build from the IDE. A shell export does not reach an Xcode opened from the Dock, so one setup can build the stubs on a laptop and the gamma sources on CI. If you do not use gamma, leave it unset everywhere.

# CI and terminal builds with the gamma sources
RNS_GAMMA_ENABLED=1 xcodebuild -project ios/App.xcodeproj \
  -scheme App -configuration Release -sdk iphonesimulator build

Forwarding headers instead of header maps

SwiftPM has no CocoaPods header maps, and the ios/ headers import each other by bare name across subfolders. So the package ships a public folder of one-line forwarding headers (#import "../../ios/..."), 77 for the default build and 149 with gamma, plus 19 header search paths kept by hand (27 with gamma). The package.json scripts show a generate-spm-public-headers script and a lint-ios check that compares them; the script itself lives in the repository, not in the npm package. If you patch screens with patch-package and add a header, the forwarding folder will not know about it.

The manifest also excludes every non-source top-level folder (node_modules, android, the example apps and others) so SwiftPM does not crawl them, which matters when screens is linked from a monorepo checkout.

New iOS props in 4.31

The JavaScript types and the native enums agree on these additions:

Prop Values Where it works
headerConfig.minimizationBehavior automatic, never, onScrollDown, onScrollUp iOS 27 or later, built with the iOS 27 SDK
restorationBehavior automatic, atScrollEdge iOS 27 or later
safeAreaAdjustment automatic, enabled, disabled iOS 27 or later
sheetBackgroundEffect automatic (Liquid Glass on iOS 26), color form sheets; no effect below iOS 26.1
sheetRef.selectDetent() detent index or 'last' presented form sheets
titleLetterSpacing, largeTitleLetterSpacing, backTitleLetterSpacing points (kern) iOS; title spacing also on Android
tab screen animation default, none tabs

The minimization code is wrapped in RNS_IPHONE_OS_VERSION_AVAILABLE(27_0) and @available(iOS 27.0, *), and sets navigationItem.navigationBarMinimization with a UIBarMinimization object. Two details from the source matter if you build with Xcode 26 and the iOS 26 SDK. First, the code is compiled out, so the prop does nothing at all. Second, on an older iOS the library logs [RNScreens] minimizationBehavior is supported for iOS >= 27 when you pass anything other than automatic. When you leave the prop out, a translucent header gets automatic and an opaque one gets never, so existing apps keep their behaviour after the upgrade.

The number of iOS 27 SDK guards in ios/ went from 22 to 32 between the two versions, so more of screens now depends on which SDK you build with. That ties in with what we found about iPhone Duo builds on the iOS 26, 27 and 27.1 SDKs.

Android: nothing changes for your app

Android build.gradle defaults in react-native-screens 4.30.1 and 4.31.0

The Kotlin and AGP numbers look like a big jump, but read where they are used. In android/build.gradle the AGP 9.2.1 and Spotless classpaths sit inside if (isRunningInContextOfScreensRepo), which is true only when the library is the root project, that is, when the screens repository is built on its own. rnsDefaultKotlinVersion is used only in that same block. Inside your app, your root project’s AGP and Kotlin versions still decide.

The Android code changes are behavioural: a new InsetsObserverView (an invisible child view so screens observes window insets without competing with other libraries for the decor view’s listener) and ScrollStopsAtTopBottomSheetBehavior, which stops a drag that starts on a scrolled list at the list’s top instead of dismissing a single-detent sheet mid-gesture. Both are internal, so there is no new API to adopt.

What to check on your own app

  1. CocoaPods users: upgrade as usual; the podspec did not change.
  2. SwiftPM users: add screens through React Native’s SwiftPM autolinking, not by URL, and run npx react-native spm scaffold (or your CLI’s equivalent) after the upgrade so the ios/build layout exists.
  3. Decide on RNS_GAMMA_ENABLED once and set it the same way in the terminal, CI and Xcode.
  4. If you patch-package screens and add headers, regenerate the forwarding headers in the repository first.
  5. Do not ship minimizationBehavior expecting it to work on an Xcode 26 build: it needs the iOS 27 SDK.
  6. tvOS and visionOS targets: the podspec declares them, the manifest declares only iOS 15, so keep TV targets on the path you have tested.

For the earlier 5.0 beta work on iPhone Duo navigation bars, see react-native-screens 5.0 beta.2: axisBehavior for iPhone Duo bars.

Made by the team behind this post

Apps from our studio

  • Goes with this post

    Cardigami

    Pop-up greeting cards that rise out of the fold on iPhone Duo.

    iPhone · App Store

    Get
  • Nix

    The Mac uninstaller that finds what the Trash leaves behind: caches, logs, derived data and saved states.

    macOS

    Get
  • BMDB.fun

    Your Bollywood world at a glance, with links straight to the OTT app that streams each film.

    Android TV · Web · Mobile

    Get
  • OneClick QuitAll

    Quit every running app in one click. See memory and CPU first.

    macOS · Mac App Store

    Get

Need this built? Let’s talk.

We build and run apps for Mac, TV, mobile and the web, and write about what we learn.