title: Handling Firebase 5 Authentication Errors In Swift 4
body: <p>We have an existing project which has been recently updated to Firebase 5, Swift 4 and our Authentication error handling doesn't appear to be working.</p>
  
  <p>I found several answers here on SO, but those no longer appear to be applicable:</p>
  
  <p><a href="https://stackoverflow.com/questions/39054162/handling-errors-in-new-firebase-and-swift">Error Handling</a></p>
  
  <p><a href="https://stackoverflow.com/questions/50732505/how-to-fetch-error-code-from-firebase/50733577#50733577">Auth Codes</a></p>
  
  <p>Suppose a user is logging in and they enter a valid email and invalid password, which are passed to the following code to authenticate</p>
  
  <pre><code>Auth.auth().signIn(withEmail: user, password: pw, completion: { (auth, error) in
      if error != nil {
          let errDesc = error?.localizedDescription
          print(errDesc!) //prints 'The password is invalid'
          let err = error!
          let errCode = AuthErrorCode(rawValue: err._code)
          switch errCode {
          case .wrongPassword: //Enum case 'wrongPassword' not found in type 'AuthErrorCode?'
              print("wrong password")
          default:
              print("unknown error")
          }
      } else {
          print("succesfully authd")
      }
  })
  </code></pre>
  
  <p>Previously, we could use FIRAuthErrorCode to compare to possible errors such as FIRAuthErrorCodeInvalidEmail, FIRAuthErrorCodeWrongPassword etc but the code posted above won't compile due to this the error on this line</p>
  
  <pre><code>case .wrongPassword:   Enum case 'wrongPassword' not found in type 'AuthErrorCode?'
  </code></pre>
  
  <p>oddly, if I use autofill by typing</p>
  
  <pre><code>case AuthErrorCode.wr
  </code></pre>
  
  <p>.wrongPassword is a selectable option and when seleted the compiler shows</p>
  
  <pre><code>Enum case 'wrongPassword' is not a member of type 'AuthErrorCode?'
  </code></pre>
  
  <p>even though it was a selectable option.</p>