You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firebase Database引用报错:未解析标识符'Database'问题咨询

解决Firebase中“Use of unresolved identifier 'Database'”报错

我最近在iOS项目中集成Firebase时碰到了个棘手的问题:明明已经完成了Firebase .plist文件的导入,也安装了Firebase、FirebaseDatabase、FirebaseAuth、FirebaseCore、FirebaseInstanceID这些相关Pods,代码写法也和官方文档示例保持一致,但运行时还是弹出了报错。

我的代码示例:

import UIKit
import Firebase

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        FirebaseApp.configure()
        let myDatabase = Database.database().reference() // 此处报错
        return true
    }
}

错误信息:

Use of unresolved identifier 'Database'

我实测有效的解决步骤:

  • 先关闭当前的Xcode项目
  • 打开终端进入项目根目录,执行命令 pod deintegrate 彻底移除已安装的Pods依赖
  • 接着执行 pod install 重新安装所有配置好的Firebase相关Pods
  • 最后一定要用项目的YourProjectName.xcworkspace文件打开项目,重新编译运行

做完这些操作后,Database未识别的问题就顺利解决了。

内容的提问来源于stack exchange,提问作者Abdo23

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:03:00