0

Please note I am a complete novice to Xcode10.1.

I have implemented Firebase authentication to my mobile app in Xcode; login works, but I am receiving an error message

Conditional cast from 'BaseViewController' to 'FUIAuthDelegate' always succeeds

and the symptoms that I am seeing is that the login screen will only appear when I completely shutdown Xcode and restart the application.

Unable to find any reference to this error on the web

class BaseViewController: UIViewController, SlideMenuDelegate, FUIAuthDelegate {
    override func viewDidLoad() {
        super.viewDidLoad()
        addSlideMenuButton()
        // Do any additional setup after loading the view.
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        if Auth.auth().currentUser != nil {
        } 
        else {
            let authUI = FUIAuth.defaultAuthUI()
            authUI?.delegate = self as? FUIAuthDelegate ***this is where im receiving the error***

            let providers: [FUIAuthProvider] = [
                FUIGoogleAuth()]

            authUI?.providers = providers
            let authViewController = authUI!.authViewController()
            self.present(authViewController, animated: true, completion: nil)
        }
    }
}
AS Mackay
  • 2,831
  • 9
  • 19
  • 25
Erinballs
  • 3
  • 5

1 Answers1

1

First of all the error is a warning (yellow).

If a class/struct adopts a protocol it becomes the protocol in terms of the compiler, so BaseViewController is FUIAuthDelegate.

The conditional cast is redundant, that's what the warning is telling you.

let authUI = FUIAuth.defaultAuthUI()!
authUI.delegate = self
vadian
  • 274,689
  • 30
  • 353
  • 361