How to fix "RCTStatusBarManager module requires that the UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO"

Viewed 1839

In my app I use React Native (legacy code) and iOS native components.

Recently I implemented preferredStatusBarStyle override in my iOS ViewController.

But preferredStatusBarStyle doesn't work without View controller-based status bar appearance = YES in Info.plist. So I changed this key to YES.

Now I have a React Native error: "RCTStatusBarManager module requires that the UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO".

Error screenshot.

Is there any way how to remove error without changing .plist back? I searched all legacy react code and didn't find any use of StatusBar React Component.

1 Answers

I can't solve this problem by using modern preferredStatusBarStyle because of React Native error. But this old deprecated way to set status bar style helped: UIApplication.shared.setStatusBarStyle().

I wrote this helper to change statusBar style in my app:

public static func updateStatusBarStyle(isLightBackground: Bool) {
  var statusBarStyle: UIStatusBarStyle
  if isLightBackground, #available(iOS 13.0, *) {
    statusBarStyle = .darkContent
  } else {
    statusBarStyle = isLightBackground ? .default : .lightContent
  }
  UIApplication.shared.setStatusBarStyle(statusBarStyle, animated: true)
}
Related