firebase / firebase/firebase-ios-sdk
FR: improve Crashlytics support for Kotlin Native
- Dominant language
- C++
- Stars
- 6.7k
- Forks
- 1.8k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 72
Description
### Feature proposal
* Firebase Component: Crashlytics
Kotlin handles exceptions quite differently from Swift/ObjC.
We can already map a Kotlin `Exception` to a `FIRExceptionModel`,
but there are currently 2 missing APIs to fully support Kotlin Native:
1. `FIRExceptionModel` doesn't have an API to store the [`cause`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/cause.html) of an exception.
2. there is currently no way to manually record a fatal exception.
In case an unhandled Kotlin exception reaches ObjC, Kotlin will terminate the program. This results in a `SIGABRT` crash in Crashlytics. There is a [hook](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.native/set-unhandled-exception-hook.html) so it would be great if we could manually record the fatal exception.
I think adding the following APIs would suffice:
```objective-c
@interface FIRExceptionModel ()
@property(nonatomic, nullable) FIRExceptionModel *cause;
@end
@interface FIRCrashlytics ()
- (void)recordFatalException:(FIRExceptionModel *)exceptionModel;
@end
```
I have been [playing](https://github.com/rickclephas/NSExceptionKt/blob/f8c0a72ee0fa9a20fdaea91fa39fae778f191ab2/nsexception-kt-crashlytics/README.md) with this and IMO nr 2 should be fairly straight forward.
All the logic is there we just need to expose the API.
For nr 1 I am not sure about the impact. It seems like the iOS SDK doesn't know the caused by concept, but on the other hand the Crashlytics backend does (since it's common for Android).
Would love to make a contribution, but I wouldn't know where to start (especially for nr 1).
Contributor guide
Assessment
This issue has not been assessed yet.