rickclephas / NSExceptionKt

A Kotlin Multiplatform Library to improve crash reports on Apple platforms
MIT License
181 stars 12 forks source link

Conflict between cocoapods.Sentry.SentryEvent and the SentryEvent from this library #7

Closed tfcporciuncula closed 8 months ago

tfcporciuncula commented 1 year ago

I'm following the "Add dependencies on a Pod library" docs to add Sentry as a dependency on the Kotlin side because I want to be able to write my own Kermit integration, also on the Kotlin side.

After integrating NSExceptionKt, I realized I'm unable to finish the setup because when I try to call this:

options?.setBeforeSend { event ->
  dropKotlinCrashEvent(event)
}

I get this error:

Type mismatch. Required: cocoapods.Sentry.SentryEvent? Found: com.rickclephas.kmp.nsexceptionkt.sentry.cinterop.SentryEvent?

I believe this is the culprit, as we're trying to add Sentry already as part of NSExceptionKt. Is there anything I can do on my end to work around this issue?

rickclephas commented 1 year ago

Hi @tfcporciuncula, thanks for the feedback! This is a limitation of the used cinterop approach, both types are actually the same though they have different packages in Kotlin. I did some quick testing and you should be able to force cast the event:

import com.rickclephas.kmp.nsexceptionkt.sentry.cinterop.SentryEvent as NSExceptionKtSentryEvent

options?.setBeforeSend { event ->
  dropKotlinCrashEvent(event as NSExceptionKtSentryEvent?) as SentryEvent?
}

Let me know if that is also working in your application.

tfcporciuncula commented 1 year ago

Thanks for the quick response! This definitely compiles in our project and so far everything seems to be working as expected 🎉

I'm still wrapping my head around a good setup on our side so I might still be missing something, but so far so good and I'll report back if I find any issues.

hbmartin commented 1 year ago

I'm getting a dyld[58117]: missing symbol called in asSentryException as https://github.com/rickclephas/NSExceptionKt/blob/222bd7a5e0a8e8c1b6bb133257246ea1a83581dc/nsexception-kt-sentry/src/commonMain/kotlin/com/rickclephas/kmp/nsexceptionkt/sentry/Sentry.kt#L90C9-L90C52 , is that related? What Sentry version were the headers pulled from, thinking I might try to exactly match that.

rickclephas commented 1 year ago

@hbmartin that doesn't seem related. Could you please create an issue for that with the exact error and missing symbol? The symbols should all be available in the Sentry v7.21.0.

rickclephas commented 8 months ago

As of v1.0.0-BETA-1 the Kotlin implementation of NSExceptionKt no longer depends on specific reporter implementations. Note: the Sentry implementation is now deprecated in favour of the official Sentry Kotlin Multiplatform SDK.