正在更新到新的firebase。在VC中创建了一个新的signin,一切都工作得很好,没有错误。
现在突然间,我的VC上到处都是未解析的标识符'FIRAuth‘的错误用法。
我试着重新安装pods文件,但没有任何运气,似乎有时如果它添加"import Firebase“,然后删除它,应用程序将编译,似乎没有押韵或原因,它有时工作,有时不能:
下面是我的代码:
import UIKit
import FirebaseAuth
class SignInViewController: UIViewController {
@IBOutlet weak var emailField: UITextField!
@IBOutlet weak var passwordField: UITextField!
override func viewDidAppear(animated: Bool) {
if let user = FIRAuth.auth()?.currentUser { //error here
self.signedIn(user)
}
}
@IBAction func didTapSignIn(sender: AnyObject) {
// Sign In with credentials.
let email = emailField.text
let password = passwordField.text
FIRAuth.auth()?.signInWithEmail(email!, password: password!) { //error here (user, error) in
if let error = error {
print(error.localizedDescription)
return
}
self.signedIn(user!)
}
}
@IBAction func didTapSignUp(sender: AnyObject) {
let email = emailField.text
let password = passwordField.text
FIRAuth.auth()?.createUserWithEmail(email!, password: password!) { // error here(user, error) in
if let error = error {
print(error.localizedDescription)
return
}
self.setDisplayName(user!)
}
}
func setDisplayName(user: FIRUser) {
let changeRequest = user.profileChangeRequest()
changeRequest.displayName = user.email!.componentsSeparatedByString("@")[0]
changeRequest.commitChangesWithCompletion(){ (error) in
if let error = error {
print(error.localizedDescription)
return
}
self.signedIn(FIRAuth.auth()?.currentUser) //error here
}
}
@IBAction func didRequestPasswordReset(sender: AnyObject) {
let prompt = UIAlertController.init(title: nil, message: "Email:", preferredStyle: UIAlertControllerStyle.Alert)
let okAction = UIAlertAction.init(title: "OK", style: UIAlertActionStyle.Default) { (action) in
let userInput = prompt.textFields![0].text
if (userInput!.isEmpty) {
return
}
FIRAuth.auth()?.sendPasswordResetWithEmail(userInput!) { //error here (error) in
if let error = error {
print(error.localizedDescription)
return
}
}
}
prompt.addTextFieldWithConfigurationHandler(nil)
prompt.addAction(okAction)
presentViewController(prompt, animated: true, completion: nil);
}
func signedIn(user: FIRUser?) {
MeasurementHelper.sendLoginEvent()
AppState.sharedInstance.displayName = user?.displayName ?? user?.email
AppState.sharedInstance.photoUrl = user?.photoURL
AppState.sharedInstance.signedIn = true
NSNotificationCenter.defaultCenter().postNotificationName(Constants.NotificationKeys.SignedIn, object: nil, userInfo: nil)
// performSegueWithIdentifier(Constants.Segues.SignInToFp, sender: nil)
}
}
有人知道为什么会发生这样的事情吗?
发布于 2016-06-03 05:42:27
我更新了Cocoapods并运行了pod更新,它解决了我所有的问题
发布于 2016-12-26 15:14:09
使用Swift 3
和Firebase 3.11.0
更新2016/12/26
添加到Podfile
pod 'Firebase/Auth'
在您的位置,您需要使用Auth,只需
import Firebase
清理并重建,您将清除错误。
这个解决方案来自Google。https://firebase.google.com/docs/auth/ios/password-auth
发布于 2017-07-10 04:02:02
你必须添加pod ' Firebase / Auth‘在pod文件,导入Firebase和FirebaseAuth到你的控制器,现在使用认证不是FIRAuth.auth()
,是Auth.auth().signInAnonymously
和工作的很好。
https://stackoverflow.com/questions/37345465
复制相似问题