getsentry / sentry-kotlin-multiplatform

Sentry SDK for Kotlin Multiplatform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not working for IOS in a Multi Module KMP Project

Vaibhav2002 opened this issue · comments

Platform

Apple

Installed

CocoaPods

Version

0.7.1

Steps to Reproduce

App Crashes as well as manual Sentry.captureException() does not work on iOS

Sample Reproducer Repo - https://github.com/Medial-Tech/Medial-App-Reproducer
Sentry initialization code in shared-core module - https://github.com/Medial-Tech/Medial-App-Reproducer/blob/main/shared/core/src/commonMain/kotlin/com/medial/app/core/SentryHelper.kt

Sentry wrapper in Umbrella module, which is exposed to native android and iOS - https://github.com/Medial-Tech/Medial-App-Reproducer/blob/main/shared/src/commonMain/kotlin/com/medial/app/Sentry.kt

Expected Result

It should be captured and shown in Sentry web console

Actual Result

Nothing is logged or captured

you are not initializing the sdk on iOS

import SwiftUI
import shared

@main
struct iOSApp: App {
    init() {
        // this was missing
        Sentry().doInit()
    }
    
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

I installed the sample locally and added the mentioned fix above and it works fine.

Make sure the Sentry init function is called.