Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FirebaseIOS: Use of Undeclared Type 'DatabaseReference'

Sorry for the weird question

Yesterday I had to update my firebase pod, before that everything was fine, but after that, I can't retrieve data anymore

So here's my code

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

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

I read the official firebase setup instructions, those are right, but I don't know why it says undeclared

For reference, here's my full code

 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()



    })
}

the 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'
like image 387
Caplin YT Avatar asked Aug 06 '17 17:08

Caplin YT


2 Answers

Swift Version 5, Firebase (6.5.0), FirebaseAnalytics (6.0.4), FirebaseDatabase (6.0.0)

Follow steps on the Google's Page

Earlier use of import FirebaseDatabase has been removed. Use only import Firebase in a Swift file and to use a database reference a variable can be used as var firebaseDatabaseRef: DatabaseReference!

If the issue persist please try to clean and build a project couple of times or use following commands from the terminal and try to clean and build again.

$pod deintegrate

and then

$pod install

Podfile:

pod 'Firebase/Analytics'
pod 'Firebase/Database'
like image 179
Pratik Avatar answered Oct 16 '22 10:10

Pratik


Be sure to add an import of firebase database in the file you call DatabaseReference and not just import Firebase alone

 import FirebaseDatabase
like image 31
Gabriel Diez Avatar answered Oct 16 '22 10:10

Gabriel Diez