无法将模块“fireBaseDatabase”加载为“FirebaseDatabase”
Posted
技术标签:
【中文标题】无法将模块“fireBaseDatabase”加载为“FirebaseDatabase”【英文标题】:Cannot load module 'fireBaseDatabase' as 'FirebaseDatabase' 【发布时间】:2017-06-13 20:54:03 【问题描述】:所以我是 Firebase 的新手,我正在关注这个关于如何将 Swift 应用程序连接到 Firebase 的教程,这完全适合他。但是当我尝试导入“FirebaseDatabase”时,它给了我这个错误;
我想知道如何解决这个问题。谢谢。
这是我的 podfile;
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'FIRBaseQuickStart' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for FIRBaseQuickStart
pod ‘Firebase’
pod ‘Firebase/Database’
end
现在,当我尝试运行应用程序时,它会显示“线程 1:信号 SIGABRT”。
import UIKit
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
FirebaseApp.configure()
return true
func applicationWillResignActive(_ application: UIApplication)
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
func applicationDidEnterBackground(_ application: UIApplication)
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
func applicationWillEnterForeground(_ application: UIApplication)
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
func applicationDidBecomeActive(_ application: UIApplication)
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
func applicationWillTerminate(_ application: UIApplication)
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
它在类声明行给我错误。这太令人沮丧了。
【问题讨论】:
您能否更新您的问题以包含与此相关的代码?你是说你试图在班级顶部写import FirebaseDatabase
?我想帮忙,但我不太清楚你的意思。
你找到解决方案了吗?
【参考方案1】:
如果您使用的是最新 (4.0) 版本的 Firebase
,您只需使用我从文档中了解到的 import Firebase
。
对于数据库引用:
var ref: DatabaseReference!
ref = Database.database().reference()
你可以找到它here
试试看。希望对您有所帮助。
【讨论】:
这没有帮助。 XCode 也不会自动完成“数据库”或“FIRDatabase”,但它会识别“Firebaseapp.configure()”并自动完成它。此外,当我尝试导入诸如“Firebase”方法之类的内容时,自动完成功能会将它们用红线划掉。 @EgeKaanGürkan 这是个愚蠢的问题,但是。您是否构建了您的项目(几乎有错误)?它从 POD 开始构建。只有在它之后你才能使用它们。 @EgeKaanGürkan 你能提供你的 podfile 吗? @EgeKaanGürkan 我昨天更新了我的豆荚。这段代码工作正常。 import FirebaseDatabase struct Post static var refToMainDataBaseNode = Database.database().reference(withPath: "MainDataBase") @EgeKaanGürkan 所以尝试更改导入行【参考方案2】:原来是因为项目名。我把它当作'fireBaseDatabase',结果发现事情变得复杂了。我刚刚用另一个名称创建了另一个项目,现在可以了!
【讨论】:
以上是关于无法将模块“fireBaseDatabase”加载为“FirebaseDatabase”的主要内容,如果未能解决你的问题,请参考以下文章
DatabaseReference和FirebaseDatabase - 无法解析符号
未能获取 FirebaseDatabase 实例。在 FirebaseApp 中指定 DatabaseURL