title: Firebase - iOS Swift: FIRAuth.auth().signOut() not signing out current user
body: <p>I'm building an app using Firebase with an initial <code>SignInViewController</code> that loads a sign in page for users to authenticate with email which triggers the following methods:</p>
  
  <pre><code>@IBAction func didTapSignIn(sender: AnyObject) {
      let email = emailField.text
      let password = passwordField.text
      FIRAuth.auth()?.signInWithEmail(email!, password: password!) { (user, error) in
          if let error = error {
              print(error.localizedDescription)
              return
          }
          self.signedIn(user!)
      }
  }
  
  func signedIn(user: FIRUser?) {
      AppState.sharedInstance.displayName = user?.displayName ?? user?.email
      AppState.sharedInstance.signedIn = true
      NSNotificationCenter.defaultCenter().postNotificationName(Constants.NotificationKeys.SignedIn, object: nil, userInfo: nil)
      performSegueWithIdentifier(Constants.Segues.SignInToHome, sender: nil)
  }
  </code></pre>
  
  <p>The <code>SignInViewController</code> also checks if there is a cached current user when the app launches and, if so, signs that user in:</p>
  
  <pre><code>override func viewDidAppear(animated: Bool) {
      super.viewDidAppear(true)
      //Synchronously gets the cached current user, or null if there is none.
      if let user = FirebaseConfigManager.sharedInstance.currentUser {
          self.signedIn(user)
      }
  }
  </code></pre>
  
  <p>Once the user is signed in, the app segues to a <code>HomeScreenViewController</code> which displays a "Sign Out" button at the top left of the navigation bar. When a user taps the "Sign Out" button, that user is supposed to get signed out and the app should segue back to the <code>SignInViewController</code> with the following method:</p>
  
  <pre><code>@IBAction func didTapSignOut(sender: UIBarButtonItem) {
      print("sign out button tapped")
      let firebaseAuth = FIRAuth.auth()
      do {
          try firebaseAuth?.signOut()
          AppState.sharedInstance.signedIn = false
          dismissViewControllerAnimated(true, completion: nil)
      } catch let signOutError as NSError {
          print ("Error signing out: \(signOutError)")
      } catch {
          print("Unknown error.")
      }
  }
  </code></pre>
  
  <p>When I tap the "Sign out" button, the <code>didTapSignOut</code> method gets called and gets executed.
  However, after the <code>try firebaseAuth?.signOut()</code> line of code gets executed, the current user should be <code>nil</code>. But when I print out the current user in the Xcode console, the current user is still logged in:</p>
  
  <pre><code>po FIRAuth.auth()?.currentUser
  ▿ Optional&lt;FIRUser&gt;
    - Some : &lt;FIRUser: 0x7fde43540f50&gt;
  </code></pre>
  
  <p>Since the current user doesn't get signed out after <code>firebaseAuth?.signOut()</code> gets called, once the app segues back to the <code>SignInViewController</code> the app still thinks there is a cached current user so that user gets signed in again.</p>
  
  <p>Could this be a Keychain issue?</p>
  
  <p>Does it have to do with <code>NSNotificationCenter.defaultCenter().postNotificationName</code> being called?</p>
  
  <p>My code comes directly from the Google Firebase Swift Codelab so I'm not sure why it's not working:
  <a href="https://codelabs.developers.google.com/codelabs/firebase-ios-swift/#4" rel="noreferrer">https://codelabs.developers.google.com/codelabs/firebase-ios-swift/#4</a></p>