0

I have been struggling with this issue for a few days, I am a rookie and I am not able to find a solution. I am trying to create a user sign up and log in page using XCode 8.3.3 and am using Firebase as database.

My code is as follows:

import UIKit import Firebase import FirebaseAuth class SignUpViewController: UIViewController { //Outlets @IBOutlet weak var emailTextField: UITextField! @IBOutlet weak var passwordTextField: UITextField! //Sign Up Action for email @IBAction func createAccountAction(_ sender: AnyObject) { if emailTextField.text == "" { let alertController = UIAlertController(title: "Error", message: "Please enter your email and password", preferredStyle: .alert) let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil) alertController.addAction(defaultAction) present(alertController, animated: true, completion: nil) } else { FIRAuth.auth().createUser(withEmail: emailTextField.text!, password: passwordTextField.text!) { (user, error) in if error == nil { print("You have successfully signed up") //Goes to the Setup page which lets the user take a photo for their profile picture and also chose a username let vc = self.storyboard?.instantiateViewController(withIdentifier: "Home") self.present(vc!, animated: true, completion: nil) } else { let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert) let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil) alertController.addAction(defaultAction) self.present(alertController, animated: true, completion: nil) } } } } 

The part that has issue is FIRAuth.auth. The error says "FIRAuth has been renamed to Auth" and if I applied such fix, although the built became successful, I could only see nothing but a white screen. If I delete the code then I can see a normal sign in screen created earlier.

Another thing is when I type import FirebaseAuth a red line appeared in the suggested word list that crossed out FirebaseAuth, I still proceeded.

Please help. I don't know why it happens. Could there be any missing pod files? Much appreciated.

Storyboard: storyboard

8
  • Did you configure Firebase in AppDelegate? Commented Jun 15, 2017 at 5:21
  • Try removing import FirebaseAuth. Commented Jun 15, 2017 at 5:22
  • Update your pods to Firebase SDK 4.0 Commented Jun 15, 2017 at 5:32
  • Yes in AppDelegate I have FirebaseApp.configure() Commented Jun 15, 2017 at 5:42
  • @ArpitJain how do I update the SDK? I tried pod update in the terminal. Commented Jun 15, 2017 at 5:44

2 Answers 2

9

FIRAuth became a Auth in last Firebase version. link to Docs

import Firebase 

Then, in the application:didFinishLaunchingWithOptions: method, initialize the FirebaseApp object:

// Use Firebase library to configure APIs FirebaseApp.configure() 

Now you can use in your file (also import Firebase)

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

Hope it helps

Sign up to request clarification or add additional context in comments.

12 Comments

I tried, and the built was successful. But I got a white screen, not my initial signup screen
@AndrewQin have you inited rootviewcontroller?
@AndrewQin Check for navigation flow
@AndrewQin In App delegate in function func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { you need to have like self.window?.rootViewController = self.storyboard?.instantiateViewController(withIdentifier: "LoginController") or set initial view controller in storyboard.
I have it as initial view controller
|
0

You need to put this line into your pod file- pod 'Firebase/Auth'. do pod install after and you should be able to do get rid of the errors regarding Auth.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.