title: thread 1: exception: presentingviewcontroller must be set. (Swift)
body: <p>I am trying to implement the google sign in button for my app in swift and I copied the code from the google dev website but whenever I run the app and click the google sign in button i get the &quot;thread 1: exception: presentingviewcontroller must be set.&quot; error. My view controller is correct as it is the same to the google dev site code. Is something wrong with anything else?
  <a href="https://i.stack.imgur.com/go2KY.png" rel="nofollow noreferrer">Error image</a></p>
  <pre><code>import UIKit
  import GoogleSignIn
  //import FBSDKLoginKit
  
  
  @objc(ViewController)
  // [START viewcontroller_interfaces]
  
  class ViewController: UIViewController {
      
      // [START viewcontroller_vars]
      @IBOutlet weak var signInButton: GIDSignInButton!
      @IBOutlet weak var signOutButton: UIButton!
      @IBOutlet weak var disconnectButton: UIButton!
      @IBOutlet weak var statusText: UILabel!
      // [END viewcontroller_vars]
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view.
          GIDSignIn.sharedInstance()?.presentingViewController = self
          
  
            // Automatically sign in the user.
            GIDSignIn.sharedInstance()?.restorePreviousSignIn()
  
           // [START_EXCLUDE]
            NotificationCenter.default.addObserver(self,
                selector: #selector(ViewController.receiveToggleAuthUINotification(_:)),
                name: NSNotification.Name(rawValue: &quot;ToggleAuthUINotification&quot;),
                object: nil)
  
            statusText.text = &quot;Initialized Swift app...&quot;
            toggleAuthUI()
            // [END_EXCLUDE]
          }
          // [END viewdidload]
      
    
  </code></pre>