iosfirebase

How to know when exactly FirebaseApp.configure() is done?


Before using Firebase SDK, we must run the code

 FirebaseApp.configure() 

The documentation says it will throw an error if something fails, but it returns nil, and I don't know how can I know exactly when it will be done.


Solution

  • From the documentation of configure:

    Configures the default Firebase app with the provided options. The default app is named __FIRAPP_DEFAULT. Raises an exception if any configuration step fails. This method is thread safe.

    It says that "This method is thread safe and contains synchronous file I/O", which means its job will be finished before the next line executes, as opposed to something that's asynchronous, like UIViewController.present(_:animated:completion:), which might not complete presenting the VC before the next line executes.