Search code examples
iosswiftfirebasefirebase-crash-reporting

Firebase Crash pod breaks device rotation on iOS


Configuring Firebase following their best practices guidance, and using the "Firebase/Crash" pod, breaks device rotation in a clean iOS project created in Xcode 8.1 using Swift 3 targeting iOS 10.1.

Steps to reproduce

  1. Create a new iOS project (e.g. using the iOS template "Tabbed Application").
  2. Add the "Firebase/Core" and "Firebase/Crash" pods to your podfile, install the pods, and open the newly created workspace file for your project.
  3. Add the corresponding GoogleService-Info.plist file to your project.
  4. Override init() in your app delegate to configure Firebase as shown below.
  5. Observe that the deployment info for your app target has ticked boxes under "Device Orientation" for "Portrait", "Landscape Left" and "Landscape Right".
  6. Run the app in the simulator, and rotate left or right.

Configuring Firebase

Firebase should be configured in AppDelegate.swift as follows:

override init() {
    super.init()
    FIRApp.configure() // This line breaks rotation if "Firebase/Crash" is installed.
}

Firebase's "best practices" guidance for iOS states that things "can go wrong" when Firebase is not configured by overriding init() in the app delegate. The implication is that it is a programming error to configure Firebase in application(_:didFinishLaunchingWithOptions:). If the latter approach is taken, however, device rotation functions as expected.

Other SO answers also recommend following Firebase's best practices guidance.

Questions

  1. Why does configuring Firebase in this way break device rotation?
  2. If I want to use both "Firebase/Crash" and "Firebase/Database" with offline persistence enabled in the manner described in the best practices guidance, what is an appropriate way to configure Firebase without breaking device rotation?

It appears that at least one other user has encountered the same problem.


Solution

  • Firebase Support has advised that the appropriate way to configure Firebase for iOS is in application:didFinishLaunchingWithOptions: "This is a correct approach and you should not encounter any problem."

    The current documentation states that Firebase is "typically" configured using this approach.

    They also advised that the "best practices" guidance for iOS will be discussed internally to determine whether it is "still relevant or needs to be updated".