2017-08-06 52 views
2

對不起,我奇怪的問題FirebaseIOS:未聲明的類型「DatabaseReference」的使用

昨天我不得不更新我的火力吊艙,在此之前,一切都很好,但在那之後,我無法檢索數據了

因此,這裏是我的代碼

// let userID = FIRAuth.auth()?.currentUser?.uid 
    var rsef: DatabaseReference! // undeclared 

    rsef = Database.database().reference() //. undeclared 

我讀了官方火力設置說明,這些是對的,但我不知道爲什麼它說未申報

˚F或參考,這是我完整的代碼

ref.child("KurdishRsta").child((FIRAuth.auth()?.currentUser?.uid)!).childByAutoId().queryOrderedByKey().observe(.childAdded, with: 
     { (snapshot) in 
      print("Database\(String(describing: snapshot.value))") 
     let value = snapshot.value as? NSDictionary 
     let FullRsta1 = value?["Rsta"] 
     let FullMeaning1 = value?["Meaning"] 





     self.RetrivedRsta.insert(RstasFromFirebase(FullRsta:FullRsta1 as! String ,FullMeaning : FullMeaning1 as! String), at: 0) 

     self.tableview.reloadData() 



    }) 
} 

的podfile

Target 'Dictionary' do 
    # Uncomment the next line if you're using Swift or would like to use dynamic frameworks 
    use_frameworks! 
    pod 'SDWebImage', '~>3.8' 
    pod 'Firebase/Core' 
    pod 'Firebase/Auth' 
    pod 'Firebase/Storage' 
    pod 'Firebase/Database' 

    # Pods for Dictionary 
pod 'SVProgressHUD' 
pod 'SKSplashView' 
pod "FGTranslator" 
pod 'SCLAlertView-Objective-C' 
pod 'OneSignal' 
pod 'Google/Analytics' 
pod 'Firebase/Core' 
pod 'Firebase/Auth' 
pod 'Firebase/Storage' 
pod 'Firebase/Database' 
pod 'ChameleonFramework' 
pod 'QMChatViewController' 
pod 'ApiAI' 
pod 'Firebase/RemoteConfig' 
pod "ZHPopupView" 
pod 'FCAlertView' 
pod 'JSQMessagesViewController' 
pod "CZPicker" 
pod 'DTTJailbreakDetection' 
pod 'MBProgressHUD', '~> 1.0.0' 
pod 'PayPal-iOS-SDK' 
+0

您可以發佈您的pod文件並在您的代碼中導入Firebase嗎? –

+0

@GabrielDiez ofcourse,我已編輯我的帖子 –

+0

當您從命令行運行'pod過時'時會發生什麼?也許由於某種原因,如果它位於Podfile.lock文件中,它會拉動較老的依賴項。實際上,您可以檢查的另一種方式是,如果您將「DatabaseReference」替換爲「FIRDatabaseReference」,並且如果可行,則由於某種原因,它會將過時的容器拉出來。 –

回答

10

一定要添加火力數據庫的導入文件中調用DatabaseReference並不僅僅是導入火力地堡單獨

import FirebaseDatabase 
+0

謝謝。但我已經完成了這項工作,但它不起作用 –

+2

[Firebase文檔](https://firebase.google.com/docs/database/ios/start)未提及導入Firebase數據庫。雖然你的解決方案似乎對我有用! – Aodh

2

如果它在那之前工作,那麼它一定是pod文件,這裏是我的參考。

# Uncomment this line to define a global platform for your project 
# platform :ios, '9.0' 
pod 'Firebase/Core' 
pod 'Firebase/Messaging' 
pod 'Firebase/Database' 
pod 'Firebase/Crash' 
pod 'Firebase/Auth' 
pod 'FacebookCore' 
pod 'FacebookLogin' 
target 'MyAwesomeApp' do 
    # Comment this line if you're not using Swift and don't want to use 
dynamic frameworks 
    use_frameworks! 

    # Pods for MyAwesomeApp 

    target 'MyAwesomeAppTests' do 
    inherit! :search_paths 
    # Pods for testing 
    end 

    target 'MyAwesomeAppUITests' do 
    inherit! :search_paths 
    # Pods for testing 
    end 

end 
+0

謝謝,我不認爲它的podfile,我猜它的firebase'它是否在你身邊? –

+0

是的,它適用於我 –

+0

你能給我閱讀數據的代碼片段? –

相關問題