如何修复Firebase SIGABRT崩溃iOS

时间:2017-10-16 10:32:08

标签: ios swift database firebase swift4

我安装了'Firebase /数据库''Firebase / Auth'广告,我在AppDelegate didFinishLaunchingWithOptions中添加了FirebaseApp.configure()。该应用程序现在很好,但当我进入 var ref:Datab = Database.database()。reference()并运行,应用程序崩溃。

控制台: -

2017-10-16 15:57:06.876363 + 0530 TKT Church [4106:1807608] *由于未捕获的异常'FIRAppNotConfigured'终止应用,原因:'无法获取默认的Firebase数据库实例。在使用Firebase数据库之前,必须在Swift中调用[FIRApp configure]FirebaseApp.configure())。 * 第一次抛出调用堆栈: (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:以NSException类型的未捕获异常终止 (lldb)

1 个答案:

答案 0 :(得分:1)

首先配置FirebaseApp共享实例,然后创建对数据库的引用。

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