flutterfire_ui Google signin crashes in iOS

I don't know when it started happening, but flutterfire_ui's Google sign in won't work on iOS anymore. It seemed to work on my iPhone XS, but the same build would crash on my newer iPhone 13 Max Pro.

March 2023 update

I ended up figuring it out! Check out https://www.wafrat.com/fixing-googlesignin-0x10461abdc-gidsignin-signinwithconfiguration-presentingviewcontroller-hint-additionalscopes-callback-228-gidsignin-m-242/.

Original post

So I tried it in XCode and the iOS Simulator and was able to reproduce the issue. The crash details look like this:

Last Exception Backtrace:
0   CoreFoundation                	       0x1129bcd34 __exceptionPreprocess + 226
1   libobjc.A.dylib               	       0x10caa4a65 objc_exception_throw + 48
2   CoreFoundation                	       0x1129bcc22 -[NSException initWithCoder:] + 0
3   Runner                        	       0x1005d2c3e -[GIDSignIn signInWithOptions:] + 276
4   Runner                        	       0x1005d2573 -[GIDSignIn signIn] + 64
5   Runner                        	       0x10062ee93 -[FLTGoogleSignInPlugin handleMethodCall:result:] + 2643
6   Flutter                       	       0x11819e7c1 __45-[FlutterMethodChannel setMethodCallHandler:]

This GitHub issue from 2019 mentions a similar stack trace. They suggest to check the GoogleService-Info.plist file, and also double check a value in Info.plist, as explained in https://pub.dev/packages/google_sign_in#ios-integration.

So I double checked but everything looked good.

I tried more googling, but I got no good information. So I resorted to reusing my old Google Sign in implementation as custom UI in flutterfire_ui:

SignInScreen(
    auth: auth,
    providerConfigs: [
      GoogleProviderConfiguration(
        clientId: '[redacted]'
      )
    ],
    footerBuilder: (context, _) {
      return Column(
          crossAxisAlignment:
              CrossAxisAlignment.stretch,
          children: [
            Text(
              'If the above button crashed, try this one:',
            ),
            SizedBox(height: 16),
            OutlinedButton(
              child: Text('Sign in with Google'),
              onPressed: () async {
                final credentials =
                    await _signInWithGoogle();
                auth.signInWithCredential(
                    credentials);
              },
            )]);
    }

_signInWithGoogle is my own method, which simply follows the doc at https://firebase.google.com/docs/auth/flutter/federated-auth#google.

When I ran the project in the Simulator and clicked my button, it asked for some permission. When I agreed, it sent me to the Google sign in page, and everything worked as expected.

So I still don't know what it is that breaks in flutterfire_ui's Google Sign in in iOS, and I was not able to find any related ticket on flutterfire_ui's GitHub repo. Finally I am too lazy to report the issue. I'll let it go, and remove the button if the issue gets fixed.