Nitesh Nitesh - 2 months ago 31
Swift Question

Use of undeclared type 'Firebase'

I know this is one of the most asked question but still couldn't find the problem.

I tried updating pod but still this error.

import Firebase

public static func createUrlToGetMessages(threadId id: String) -> Firebase {
return Firebase(url: FIREBASE_BASE_REF)
.childByAppendingPath("chats")
.childByAppendingPath(id)
.childByAppendingPath("messages")
}
public static func createUrlToGetOneMessageRef(threadId threadId: String, messageId messageId: String) -> Firebase {
return Firebase(url: FIREBASE_BASE_REF)
.childByAppendingPath("chats")
.childByAppendingPath(threadId)
.childByAppendingPath("messages")
.childByAppendingPath(messageId)
}


enter image description here

Answer

It seems that you are using old deprecated version of Firebase.

Read the new docs for the setup details.

Your code should be like this:

import Firebase

var ref = FIRDatabase.database().reference()

public static func createUrlToGetMessages(threadId id: String) -> FIRDatabaseReference {
    return ref.child("chats").child(id).child("messages")
}

public static func createUrlToGetOneMessageRef(threadId: String, messageId: String) -> FIRDatabaseReference {
    return ref.child("chats").child(threadId).child("messages").child(messageId)
}
Comments