Files
react-native/packages/rn-tester/RNTesterUnitTests
Alan Hughes 8aea8d9bad Fix StatusBar style and visibility on iOS 27 (#58926)
Summary:
Fixes https://github.com/react/react-native/issues/58758.
In apps built with the iOS 27 SDK, `StatusBar.setBarStyle` and `StatusBar.setHidden` do nothing. `RCTStatusBarManager` uses the `UIApplication` status bar setters, and UIKit turns them into no-ops for apps linked against the iOS 27 SDK. Apps built with the iOS 26 SDK are not affected. A plain UIKit app built with the iOS 27 SDK shows that with `UIViewControllerBasedStatusBarAppearance` set to `NO`, nothing can change the status bar on iOS 27. With `YES`, the view controller methods still work.

This change moves `StatusBar` to the view controller model. The module stores the requested style, hidden state, and animation in a new `RCTStatusBarAppearance` class and calls `setNeedsStatusBarAppearanceUpdate` on the presented view controller. The default root view controller from `RCTDefaultReactNativeFactoryDelegate` and the Fabric modal controller return those values. The modal keeps the status bar that was on screen when it opened until JS changes it, so a status bar set natively (ie by react-native-screens) is not lost. With `NO`, the module still calls the `UIApplication` setters, so apps built with older SDKs keep working. When React Native is built with the iOS 27 SDK and runs on iOS 27, it also logs one warning that tells the developer to set the key to `YES`.

Apps that override `createRootViewController` need their view controller to return the `RCTStatusBarAppearance` values for `StatusBar` to work on iOS 27.

A similar change, https://github.com/react/react-native/issues/25919, landed in March 2020 and was reverted the next day

[IOS] [FIXED] - `StatusBar` style and visibility work on iOS 27 for apps built with the iOS 27 SDK when `UIViewControllerBasedStatusBarAppearance` is `YES`. Custom root view controllers must return the `RCTStatusBarAppearance` values.

Pull Request resolved: https://github.com/react/react-native/pull/58926

Test Plan:
12 new XCTest cases in `RCTStatusBarAppearanceTests`. The OSS XCTest file has no internal BUCK owner and was not run locally.

Validation for the review update:
- Applied the explicit legacy-API guard to both `setStyle:animated:` and `setHidden:withAnimation:`. The appearance-state update remains unconditional; UIKit setters and warnings remain limited to apps using app-level status bar appearance.
- Meta-managed `clang-format` and `arc lint` passed for `RCTStatusBarManager.mm`.
- Built `ReactApple`, `CoreModulesApple`, `RCTFabricApple` and `RCTAppDelegateApple` for `iphonesimulator-arm64` with annotation checks enabled.
- No public headers changed, so API snapshots are unchanged.
- Diff-time CI will rerun for the updated code.

Reviewed By: javache

Differential Revision: D127555263

Pulled By: cipolleschi

fbshipit-source-id: 9a6d21236987e309917e620387b34e88e7da24c7
(cherry picked from commit bd08dafc98)
2026-10-26 16:01:49 +00:00
..