使用未解析的标识符“ Auth”

时间:2018-12-06 19:11:06

标签: swift xcode firebase firebase-authentication cocoapods

我一直收到此错误

  

使用未解析的标识符“ Auth”

enter image description here

Auth.auth().createUser(withEmail: email, password: password) { (user, error) in

    let ref = Database.database().reference(fromURL: "https://app-project.firebaseio.com")
    let usersReference = ref.child("Users")
    let id = usersReference.childByAutoId().key

    InstanceID.instanceID().instanceID(handler: { (result, error) in
        let token = result?.instanceID
        let values = ["phone": phone,"CreatedAt":dateString,"UpdatedAt":dateString,"id":id as Any,"token":token as Any] as [String : Any]
        usersReference.child(id!).setValue(values, withCompletionBlock: { (err, ref) in
            if err != nil {
                print(err.self as Any)
                return
            }
            print("Successfully saved user in Firebase DB")

        })

    })

}

Podfile

platform :ios, '10.0'
use_frameworks!

target 'project' do
   pod 'Charts'
   pod 'SwiftyJSON'
   pod 'Firebase/Core'
   pod 'Firebase/Messaging'
   pod 'Firebase/Database'
   pod 'Firebase/Auth'
end

我已经在文件顶部使用了

import Firebase
import FirebaseDatabase

我尝试重建,但仍然看到它。

重新启动XCode,重建后仍然可以看到它。

如何进一步调试呢?

2 个答案:

答案 0 :(得分:2)

您需要

import FirebaseAuth

答案 1 :(得分:-1)

在pod文件中包含“ Firebase / Auth”。然后在终端pod安装中键入。然后导入FirebaseAuth。