0

I have installed 'Firebase/Database' 'Firebase/Auth' pods and I added FirebaseApp.configure() in AppDelegate didFinishLaunchingWithOptions. The app is fine now but when I enter var ref: Datab = Database.database().reference() and run, the app is crashing.

CONSOLE :-

2017-10-16 15:57:06.876363+0530 TKT Church[4106:1807608] * Terminating app due to uncaught exception 'FIRAppNotConfigured', reason: 'Failed to get default Firebase Database instance. Must call [FIRApp configure] (FirebaseApp.configure() in Swift) before using Firebase Database.' * First throw call stack: (0x1842e3d38 0x1837f8528 0x1842e3c80 0x102e88fcc 0x102dec660 0x102dec830 0x18dc7a8bc 0x18de23588 0x18de23700 0x18de232c0 0x18da59ebc 0x18da95fe8 0x18de23588 0x18de23700 0x18de232c0 0x18da59ebc 0x18da7650c 0x18de23588 0x18de232c0 0x18dc7a560 0x18de23588 0x18de23700 0x18de232c0 0x18dc798a0 0x18dff67f0 0x18d95c8dc 0x18d762cdc 0x18d95b5c0 0x18dbe9454 0x18deb91f0 0x18dbe90b8 0x18dbe9928 0x18e3526e8 0x18e35258c 0x18e0ce9c0 0x18e263fc8 0x18e0ce870 0x18deb8850 0x18d959e28 0x18dd5d6ec 0x186985768 0x18698e070 0x1041dd45c 0x1041e9b74 0x1869b9a04 0x1869b96a8 0x1869b9c44 0x18428c358 0x18428c2d8 0x18428bb60 0x184289738 0x1841aa2d8 0x18603bf84 0x18d757880 0x102dea3b0 0x183cce56c) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

Suprem Vanam
  • 73
  • 11

1 Answers1

1

First Configure a FirebaseApp shared instance and then create a reference to your database.

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  FIRApp.configure()
  var ref: DatabaseReference!
  ref = Database.database().reference()
  return true 
}
Nishant Bhindi
  • 2,242
  • 8
  • 21