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
相关产品推荐
相关产品推荐

