Firebase应用未配置

use*_*448 8 ios firebase swift3 xcode8

这随机开始发生,我无法通过它.我的应用程序在启动时崩溃,在调试区域中.

2016-10-29 14:31:57.606 gigMe [2285:73317]启用Firebase自动屏幕报告.调用+ [FIRAnalytics setScreenName:setScreenClass:]设置屏幕名称或覆盖默认屏幕类名称.要禁用自动屏幕报告,请在Info.plist中将标志FirebaseAutomaticScreenReportingEnabled设置为NO

2016-10-29 14:31:57.783 gigMe [2285] [Firebase/Core] [I-COR000003]尚未配置默认的Firebase应用程序.将[FIRApp configure]添加到应用程序初始化.阅读更多:给我在这里发布的谷歌地址

2016-10-29 14:31:57.911 gigMe [2285:73317] *由于未捕获的异常'FIRAppNotConfigured'而终止应用程序,原因是:'无法获取默认的FIRDatabase实例.在使用FIRDatabase之前必须调用FIRApp.configure().*第一次抛出调用堆栈:

我真的不明白这一点,因为我没有搞乱任何与数据库有关的事情,这是我的didFinishLaunchingWithOptions方法:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    print("wtf")
    FIRApp.configure()

    return true
}
Run Code Online (Sandbox Code Playgroud)

我也没有在调试器中打印任何东西.有谁知道发生了什么事?

Dra*_*ian 43

这不是FIRApp.configure()错误.您可能会在任何类中声明一个具有某些类函数的全局变量,例如

class viewCon : UIViewController{

let ref = FIRDatabase.database().reference() // or a Storage reference
    // This might be the error
   }
Run Code Online (Sandbox Code Playgroud)

之所以发生这种情况,是因为,您尝试使用类函数/属性初始化变量,该函数/属性甚至可能尚未配置.试试这个: -

 class viewCon : UIViewController{

    let ref : FIRDatabaseReference! 
       // This might be the error or a Storage reference

     override func viewDidLoad(){

       super.viewDidLoad()
       ref =  FIRDatabase.database().reference()
      }
  }
Run Code Online (Sandbox Code Playgroud)

为了支持上述理论,请尝试在let ref = FIRDatabase.database().reference()和上使用断点FIRApp.configure(),并查看首先调用哪个断点.如果let ref = FIRDatabase.database().reference()首先调用,则必然会出现此错误,因为ref尝试访问FIRDatabase尚未配置的类.