Native Access to the SDK

How to directly access the SDK without the shared module.

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.9.0")
  }
}

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

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") {
    version = "~> 8.25"
    linkOnly = true
    extraOpts += listOf("-compiler-option", "-fmodules")
  }
  framework {
    baseName = "shared"
    export("io.sentry:sentry-kotlin-multiplatform:0.9.0")
  }
}

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

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

Copied
import io.sentry.kotlin.multiplatform.Sentry

Sentry.captureMessage("My message")

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").