Thread 1: signal SIGABRT error running on Xcode 11.2.1

1.1k Views Asked by At

The project(react-native) was running fine on Xcode 10.2, and to test it on iOS 13, I tried opening the project with Xcode 11.2.1 and the app crashes at startup and the error from the Xcode 11.2.1 console is below:

Assertion failure in -[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3900.12.16/UIApplication.m:5316
2019-12-10 14:26:37.206842+0530 workish[73259:574909] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'
*** First throw call stack:
1

There are 1 best solutions below

0
On BEST ANSWER

You are trying to access statusBar somewhere in your code which has deprecated since iOS 13. Below is an example code to get statusBar for iOS 13+ and below

  if #available(iOS 13.0, *) {
    let statusBarFrame = UIView(frame: UIApplication.shared.keyWindow?.windowScene?.statusBarManager?.statusBarFrame ?? CGRect.zero)
     statusBarFrame.backgroundColor = UIColor.init(red: 243/250, green: 243/250, blue: 243/250, alpha: 1)
     UIApplication.shared.keyWindow?.addSubview(statusBarFrame)
} else {
     UIApplication.shared.statusBarView?.backgroundColor = UIColor.init(red: 243/250, green: 243/250, blue: 243/250, alpha: 1)
}