LoginSignup
4
3

More than 3 years have passed since last update.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'presentingViewController must be set.' のエラー解決方法【GoogleSignIn for iOS】

Posted at

SwiftでFirebaseを使ってGoogleログインするときにでたエラーの解決方法です。

原因

出たエラーはこちら

Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 'presentingViewController must be set.'

ボタンをクリックしたときグーグル認証されるというもの。
ボタンをタップしたときに上記のエラーが起こる。

googleLogin.py
    @IBAction func loginGoogleButton(_ sender: Any) {
         GIDSignIn.sharedInstance()?.signIn()
    }

解決方法

これを

GIDSignIn.sharedInstance()?.uidelegate = self

こう変える

GIDSignIn.sharedInstance()?.presentingViewController = self

Google Sign inがバージョン5.0.0になったことで色々仕様が変わったようですね。
以下引用
公式ドキュメント
https://developers.google.com/identity/sign-in/ios/release
github
https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/1370

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3