firebase / firebase/firebase-unity-sdk
[Bug] iOS crashes when Google sign in is not enabled
- Dominant language
- C#
- Stars
- 320
- Forks
- 60
- Avg merge
- 11h 15m
- Merged PRs (30d)
- 11
Description
### Description
# Summary
Our project is using Firebase Auth to _only_ support logging into our game with Microsoft. However we were seeing a crash on iOS that was fixed by turning on Google Sign In even though we're not using it. Specifically, I needed to include the `REVERSED_CLIENT_ID` property in the `GoogleService-Info.plist`, which is only added after enabling Google Sign In.
# Detailed description
Tracking down this dependency was a bit obtuse (admittedly I didn't have a Mac handy to actually debug the crash). Since the crash was occurring without any user facing error, I initially assumed there was something wrong with our initialization code. After a few hours with no success, I submitted a crash report from my test device and pulled it from Testflight (didn't learn about this handy feature until today). In the crash report I found the exception originating from Firebase's iOS plugin, specifically `getCredentialWithUIDelegate`:
```
Incident Identifier: REDACTED
Hardware Model: iPhone14,5
Process: REDACTED [22464]
Path: /private/var/containers/Bundle/Application/REDACTED
Identifier: REDACTED
Version: 1.0.0 (484)
AppStoreTools: 15E204
AppVariant: 1:iPhone14,5:15
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: REDACTED [632]
Date/Time: 2024-04-25 14:13:57.9404 -0700
Launch Time: 2024-04-25 14:13:49.0833 -0700
OS Version: iPhone OS 15.7 (19H12)
Release Type: User
Baseband Version: 1.70.01
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 47
Last Exception Backtrace:
0 CoreFoundation 0x1d62e1288 __exceptionPreprocess + 220 (NSException.m:200)
1 libobjc.A.dylib 0x1ef015744 objc_exception_throw + 60 (objc-exception.mm:565)
2 CoreFoundation 0x1d6338390 +[NSException raise:format:] + 112 (NSException.m:156)
3 UnityFramework 0x1056160d4 -[FIROAuthProvider getCredentialWithUIDelegate:completion:] + 116 (FIROAuthProvider.m:158)
4 UnityFramework 0x1055f5f78 __52-[FIRAuth signInWithProvider:UIDelegate:completion:]_block_invoke + 124 (FIRAuth.m:655)
5 libdispatch.dylib 0x1d5f46e6c _dispatch_call_block_and_release + 32 (init.c:1517)
6 libdispatch.dylib 0x1d5f48a30 _dispatch_client_callout + 20 (object.m:560)
7 libdispatch.dylib 0x1d5f50124 _dispatch_lane_serial_drain + 668 (inline_internal.h:2622)
8 libdispatch.dylib 0x1d5f50c80 _dispatch_lane_invoke + 392 (queue.c:3944)
9 libdispatch.dylib 0x1d5f5b500 _dispatch_workloop_worker_thread + 648 (queue.c:6732)
10 libsystem_pthread.dylib 0x2474810bc _pthread_wqthread + 288 (pthread.c:2599)
11 libsystem_pthread.dylib 0x247480e5c start_wqthread + 8
```
Thankfully the source for the plugin is available, so I was able to look up [the relevant line](https://github.com/firebase/firebase-ios-sdk/blob/main/FirebaseAuth/Sources/AuthProvider/OAuth/FIROAuthProvider.m#L159) which has some extra info:
```
[NSException raise:NSInternalInconsistencyException
format:@"Please register custom URL scheme '%@' in the app's Info.plist file.",
self->_callbackScheme];
```
Then it was just a couple of Google searches to figure out that "registering a custom URL" scheme meant `REVERSED_CLIENT_ID` was missing from my `GoogleService-Info.plist`.
While I'm still pretty sure requiring Google Sign In is a bug, I think this would have been a lot easier to catch if some validation was added either when the plist is imported, or during a build step. Granted there is this log I saw at build time:
`GoogleService-Info.plist file missing REVERSED_CLIENT_ID, Google Sign-In will fail to initialize`. However I ignored it since we aren't using Google Sign In 😵
### Reproducing the issue
_No response_
### Firebase Unity SDK Version
11.7.0
### Unity editor version
2022.3.10
### Installation Method
.unitypackage
### Problematic Firebase Component(s)
Authentication
### Other Firebase Component(s) in use
_No response_
### Additional SDKs you are using
_No response_
### Targeted Platform(s)
Apple Platforms, Android
### Unity editor platform
Windows
### Scripting Runtime
IL2CPP
### Release Distribution Type
Pre-built SDK from https://firebase.google.com/download/unity
### Relevant Log Output
_No response_
### If using CocoaPods for Apple platforms, the project's Podfile.lock
Expand Podfile.lock snippet
```yml
👀 Replace this line with the contents of your Podfile.lock!
```
Contributor guide
Assessment
This issue has not been assessed yet.