使用firebase swift3时出现异常

时间:2018-01-09 14:11:53

标签: ios swift firebase firebase-realtime-database firebase-authentication

我在链接中执行此示例:

https://www.raywenderlich.com/139322/firebase-tutorial-getting-started-2

但是我得到了这个例外

  

由于未捕获的异常终止应用程序' FIRAppNotConfigured',原因:'无法获取默认的FIRDatabase实例。在使用FIRDatabase之前必须调用FIRApp.configure()。

我从同一页面下载了最终项目并获得相同的例外,即使我将 GoogleService-Info.plist 并启用了钥匙串也是如此!

感谢任何帮助

1 个答案:

答案 0 :(得分:0)

您需要在FirebaseApp.configure() AppDelegate方法中调用didFinishLaunchingWithOptions,现在firebase应用的名称为FirebaseApp,而不是FIRApp教程已过时< / p>

并使用此pod文件内容

project 'Grocr.xcodeproj'

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'

target 'Grocr' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Grocr
  pod 'Firebase/Core'
end

您还需要删除pod文件夹并执行pod install --verbose