Firebase References undeclared

前端 未结 6 1045
闹比i
闹比i 2021-02-19 20:38

I created a new Xcode project, added the \'Firebase\' pod to my pod file and installed it, and added the Google-services.plist file and the rest according to the Firebase docume

相关标签:
6条回答
  • 2021-02-19 21:17

    As in swift4 the 'FIRDatabaseReference' has been renamed to 'DatabaseReference'

    So, use:

    var ref:DatabaseReference!

    0 讨论(0)
  • 2021-02-19 21:19

    EDIT: I found the real problem behind. Firebase had update. User need to update the firebase version via cocopod. After update the cocopod, can use everything normally same as firebase Doc.

    ==========================================

    I have the same problem, but cannot fix it by updating the pod-file.

    Finally, I find out a solution.

    Google teach us to import only

    import Firebase

    Just add:

    import FirebaseDatabase

    and everything will become fine

    0 讨论(0)
  • 2021-02-19 21:23

    On your Podfile, add additional line of

    pod 'Firebase/Database'
    

    Then on your code section

    import FirebaseDatabase
    

    And it should work now, with the following code:

    var ref: DatabaseReference!
    
    0 讨论(0)
  • 2021-02-19 21:25

    In your Podfile, add pod

    pod 'Firebase/Database'
    

    Then import Firebase Database in your ViewController

    import FirebaseDatabase
    

    Create a globle var ref that you can use it anywhere in viewcontroller

    var ref: DatabaseReference!
    

    Now, In viewDidLoad Define the ref

    ref = Database.database().reference()
    
    0 讨论(0)
  • 2021-02-19 21:30

    Just had the same problem, but after a while I realized that I was missing an entry in the pod-file, your pod-file should contain:

    pod 'Firebase/Database'
    

    Hope it works now :)

    0 讨论(0)
  • 2021-02-19 21:35

    Problem solved by removing "FIR" form the words ("FIRDatabaseReference" and "FIRDatabaseHandle")

    Also that import "Firebase" in the viewController

    0 讨论(0)
提交回复
热议问题