Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase References undeclared

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 documentation.

import Firebase works fine, but if I try

var ref:FIRDatabaseReference!

in the same ViewController, then it throws an error:

Use of undeclared type 'FIRDatabaseReference'

And this happens for any Firebase References. Any ideas on this? I am very new to Swift and the xCode IDE.

like image 898
ffritz Avatar asked Jul 22 '16 09:07

ffritz


People also ask

How do references work firebase?

A Reference represents a specific location in your Database and can be used for reading or writing data to that Database location. You can reference the root or child location in your Database by calling firebase. database(). ref() or firebase.

What is orderByChild in firebase?

Firebase orderByChild once child_added is only giving one child. 0. Returning a single child's value on Firebase query using orderByChild and equalTo. 3. unspecified index when searching data with firebase cloud function on nested object running nested Query.

What is DataSnapshot in firebase?

A DataSnapshot instance contains data from a Firebase Database location. Any time you read Database data, you receive the data as a DataSnapshot.

What is addListenerForSingleValueEvent?

addValueEventListener() keep listening to query or database reference it is attached to. But addListenerForSingleValueEvent() executes onDataChange method immediately and after executing that method once, it stops listening to the reference location it is attached to. Follow this answer to receive notifications.


1 Answers

As in swift4 the FIRDatabaseReference has been renamed to DatabaseReference

So, use:

var ref:DatabaseReference

like image 50
raj Avatar answered Oct 04 '22 21:10

raj