how do I perform segue after log in with google account?
<p>I've been working on sign in with Google account.</p>

<p>I basically followed the guide from Friebase (<a href="https://firebase.google.com/docs/auth/ios/google-signin" rel="nofollow">https://firebase.google.com/docs/auth/ios/google-signin</a>)</p>

<p>It worked, but I have trouble performing segue to my main page from sign in page</p>

<p>here's the code in my signin View controller :</p>

<pre><code>class SignInController: UIViewController,  GIDSignInUIDelegate{

@IBOutlet weak var signInButton: GIDSignInButton!


override func viewDidLoad() {
    super.viewDidLoad()
    GIDSignIn.sharedInstance().uiDelegate = self
    GIDSignIn.sharedInstance().signInSilently()

    }

func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {
    if let err = error {
        print(error)
    }
    else {
        performSegue(withIdentifier: "GoToMain", sender: self)
    }
}
</code></pre>

<p>it should work if i put performSegue in the signIn function but it didn't </p>

<p>after log in with google successfully, it goes back to protected (sign in) page</p>

<p>I've been working and trying to shoot this problem for almost 6 hours, still can't figure it out !!!</p>

<p>self learning is a lot of pain.</p>

<p>any help is appreciated!!!
Thanks!!</p>

<p>Ian.</p>

<h2>update</h2>

<p>so now my code is like the following :</p>

<pre><code>class SignInController: UIViewController,  GIDSignInUIDelegate, GIDSignInDelegate {

@IBOutlet weak var signInButton: GIDSignInButton!


override func viewDidLoad() {
    super.viewDidLoad()
    GIDSignIn.sharedInstance().delegate = self
    GIDSignIn.sharedInstance().uiDelegate = self
    GIDSignIn.sharedInstance().signInSilently()
    GIDSignIn.sharedInstance().clientID = FIRApp.defaultApp()?.options.clientID


    }

public func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {


    if let authentication = user.authentication
    {
        let credential = FIRGoogleAuthProvider.credential(withIDToken: authentication.idToken, accessToken: authentication.accessToken)

        FIRAuth.auth()?.signIn(with: credential, completion: { (user, error) -&gt; Void in
            if error != nil
            {
                print("Problem at signing in with google with error : \(error)")

            }
            else if error == nil{
                print("user successfully signed in through GOOGLE! uid:\(FIRAuth.auth()!.currentUser!.uid)")

            }
        })
    }
}

func signIn(signIn: GIDSignIn!, didDisconnectWithUser user: GIDGoogleUser!, withError error: NSError!) {

}
</code></pre>

<p>I added GIDsignDeligate protocol otherwise there will be an error at line
 "GIDSignIn.sharedInstance().delegate = self"</p>

<p>When I run it, it crashed with "unexpectedly found nil while unwrapping an Optional value error" (seem to happen at "if let authentication = user.authentication"
)</p>

<p>Am i missing anything?
I feel I'm almost there!</p>