简体   繁体   English

未声明的标识符FIRAuth

[英]Undeclared Identifier FIRAuth

I am a beginner in iOS and fire base. 我是iOS和Fire Base的初学者。

  • I installed firebase cocoa pods. 我安装了火力基地可可豆荚。
  • Imported firebase.h in my loginViewcontroller.h 进口firebase.h在我loginViewcontroller.h
  • Added pod 'Firebase/Core', pod 'Firebase/Database', pod 'Firebase/Auth'. 添加了窗格“ Firebase / Core”,窗格“ Firebase / Database”,窗格“ Firebase / Auth”。

I am migrating from parse to firebase, I added following fire base authentication code in my loginViewController.m . 我正在从解析迁移到loginViewController.m在我的loginViewController.m添加了以下fire base身份验证代码。

[[FIRAuth auth] createUserWithEmail:email password:password completion:^(FIRUser *_Nullable user, NSError *_Nullable error) { // ... }];

But it shows an error called use of undeclared identifier FIRAuth . 但是它显示了一个错误,称为use of undeclared identifier FIRAuth Please help. 请帮忙。

您应该导入FirebaseAuth。

@import FirebaseAuth;

Check if, 检查一下

1) pod 'Firebase/Auth' is present or not 1)窗格'Firebase / Auth'是否存在

2) In app delegate have you configured using the below method 2)在应用程序委托中,您是否使用以下方法进行配置

@import Firebase;
// Use Firebase library to configure APIs
[FIRApp configure];

Try this i hope it would be helpful!But it's in swift 试试这个,我希望它会有所帮助!但是它很快

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]? = [:]) -> Bool {
    UIApplication.shared.statusBarStyle = .lightContent
    FIRApp.configure()

    FIRDatabase.database().persistenceEnabled = true
    return true
  }

After that you can use it like this! 之后,您可以像这样使用它!

     @IBAction func signUpDidTouch(_ sender: AnyObject)
  {
    let alert = UIAlertController(title: "Register",message: "Register",preferredStyle: .alert)

    let saveAction = UIAlertAction(title: "Save",style: .default) { action in

      let emailField = alert.textFields![0]
      let passwordField = alert.textFields![1]

      FIRAuth.auth()?.createUser(withEmail: emailField.text!, password: passwordField.text!, completion: { (user, error) in

        if error == nil{
          FIRAuth.auth()?.signIn(withEmail: self.textFieldLoginEmail.text!, password: self.textFieldLoginPassword.text!, completion: nil)
        }
      })

    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM