Native Access to the SDK

If you need to access the SDK directly in your native platform without the shared module, you first need to change the dependency configuration from implementation(...) to api(...):

shared/build.gradle.kts
Copied
val commonMain by getting {
  dependencies {
    api("io.sentry:sentry-kotlin-multiplatform:0.4.0")
  }
}

Export the Framework

If you have Apple targets, you also need to export the framework.

Cocoapods

shared/build.gradle.kts
Copied
cocoapods {
  summary = "Some description for the Shared Module"
  homepage = "Link to the Shared Module homepage"
  ios.deploymentTarget = "14.1"
  podfile = project.file("../iosApp/Podfile")
  // Make sure you use the proper version according to our Cocoa SDK Version Compatibility Table.
  pod("Sentry", "~> 8.17.2")
  framework {
    baseName = "shared"
    export("io.sentry:sentry-kotlin-multiplatform:0.4.0")
  }
}

Swift Package Manager

shared/build.gradle.kts
Copied
listOf(
  iosX64(),
  iosArm64(),
  iosSimulatorArm64()
).forEach {
  it.binaries.framework {
      baseName = "shared"
      isStatic = true
      export("io.sentry:sentry-kotlin-multiplatform:0.4.0")
  }
}

Usage

Now you can access the SDK directly in your native platform:

Android

Copied
import io.sentry.kotlin.multiplatform.Sentry

Sentry.captureMessage("My message")

iOS

Copied
import shared

Sentry.shared.captureMessage(message: "My message")
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").