Flutter: "GoogleService-Info.plist file not found," unable to sign in with Google on iOS
Conclusion: Download and replace the latest "GoogleService-Info.plist" from Firebase
Flutter Errors & Bugs Diary, May 15, 2023
After implementing the Google Sign-In feature, I found myself in a situation where, while I could sign in on Android, I couldn't sign in on iOS due to the following error.
PlatformException(missing-config, GoogleService-Info.plist file not found and clientId was not provided programmatically., null, null)
The error seems to indicate that "GoogleService-Info.plist" cannot be found. However, I properly downloaded it from the Firebase management screen and placed it under "ios/Runner" using Xcode.
Normally, following the settings according to the articles (in Japanese) I organized below, it worked without any problem.
Solving the issue by setting the 'clientId' property of the 'GoogleSignIn' class
Upon researching online, I found a report of the same error.
According to this, it is necessary to set the 'clientId' property when creating an instance of the 'GoogleSignIn' class, as follows:
// Use this GoogleSignIn instance to create a sign-in method like googleSignInO.signIn() googleSignInO = GoogleSignIn( clientId: DefaultFirebaseOptions.currentPlatform.iosClientId, // Add this (needs to import 'firebase_options.dart') scopes: [ driveO.DriveApi.driveAppdataScope, // Section to list the necessary permissions (scopes) ]); )
To use 'DefaultFirebaseOptions', it is necessary to import 'firebase_options.dart' (a file that is automatically created when introducing Firebase).
Indeed, after adding 'clientId', I was able to sign in with Google on iOS without any problem.
I thought that if I set the client ID for iOS, I wouldn't be able to sign in on Android, but for some reason, I was still able to sign in on Android.
Looking at the explanation of the 'clientId' part in the source code of the 'google_sign_in' package, there is the following description, and it seems that this property is not supported on Android.
Client ID being used to connect to google sign-in.
This option is not supported on all platforms (e.g. Android). It is optional if file-based configuration is used.
The value specified here has precedence over a value from a configuration file.
Therefore, in the case of Android, 'clientId' is skipped, so it seems that even if it is added, it has no effect.
Was 'ANDROID_CLIENT_ID' needed in 'GoogleService-Info.plist'?
Certainly, the issue was resolved by setting 'clientId', but in other apps I created, I was able to sign in with Google on iOS without setting 'clientId'.
Ideally, I don't want to set unnecessary properties.
So, I checked the settings again.
First, the part to set 'CFBundleTypeRole' in 'Info.plist' was done appropriately.
Also, the part to transcribe 'REVERSED_CLIENT_ID' from 'GoogleService-Info.plist' was completed without any problem.
※ The above are settings according to the description of the 'google_sign_in' package.
Next, I thought there might be a problem with the 'GoogleService-Info.plist' I downloaded from Firebase, so I downloaded it again and compared the contents.
Then, in the one I downloaded again, 'ANDROID_CLIENT_ID' was newly added as follows.
<key>ANDROID_CLIENT_ID</key> <string>############.apps.googleusercontent.com</string>
I wondered why 'ANDROID_CLIENT_ID' was in the configuration file for iOS, but anyway, the file seemed to have been updated, so I deleted the old 'GoogleService-Info.plist' and replaced it with the new file.
Then, even without setting the 'clientId' property, I was able to sign in on iOS without any problem.
'ANDROID_CLIENT_ID' seems to be necessary for signing in on both OS
I was wondering why 'ANDROID_CLIENT_ID' was necessary in the configuration file for iOS (GoogleService-Info.plist), so I searched online but couldn't find any information.
So, when I asked ChatGPT, the answer was as follows:
- The 'ANDROID_CLIENT_ID' in the 'GoogleService-info.plist' file is present considering that the Firebase configuration file is used on both iOS and Android platforms, which helps when iOS and Android apps are associated with the same Firebase project.
- Specifically, some Firebase services like Firebase Authentication and Firebase Dynamic Links provide features that can be used on both iOS and Android. When using these features, it's necessary to share data between iOS and Android apps.
- 'ANDROID_CLIENT_ID' is the client ID required when an Android app uses Firebase Authentication to log in with a Google account. This allows a user to automatically log into the iOS app with the same account after logging into the Android app. This way, seamless user authentication can be achieved between multiple platforms using the same Firebase project.
I see… indeed, when I was testing, I was trying to sign in with the same Google account on both Android and iOS, so maybe this setting was necessary…
On the other hand, since I had chosen to sign in with Google without using Firebase Authentication (the 'firebase_auth' package), I couldn't fully understand this part…
I can't find the source information, so I can't be sure, but anyway, I realize that I need to check on Firebase in the future to see if 'GoogleService-info.plist' has been updated.
Useful tools for personal app development
Recommended learning materials
\Aiming for the campaign period can provide comprehensive content at a low cost/