Skip to main content
The Klaritics Kotlin Multiplatform (KMP) SDK is a thin wrapper that delegates to the native Klaritics Android and iOS SDKs, so you get native batching, queueing, and session handling behind a single Kotlin API. Write your integration once in shared Kotlin; the only platform-specific line is the context you pass at setup. Artifact: com.deeptaai.klaritics:klaritics-kmp:1.0.0

Requirements

You need an App ID and a Host URL from the Klaritics dashboard.
Kotlin compatibility matters. A Kotlin/Native klib can only be consumed by an equal-or-newer Kotlin compiler. If your app is on Kotlin < 2.4, upgrade the app’s Kotlin before adding this dependency.

Add repositories

The SDK and its native Android dependency live in two public GCP Artifact Registry Maven repos. Both allow anonymous read, so no credentials are required. Add both to your app’s settings.gradle.kts:
settings.gradle.kts
Repositories are not transitive. Even though the native Android SDK is a transitive dependency, your app must declare its repo explicitly.

Add the dependency

Add it once to your shared module’s commonMain, not per platform:
shared/build.gradle.kts
Gradle Module Metadata selects the correct variant per target automatically (-android, -iosarm64, -iosx64, -iossimulatorarm64).

Initialize the SDK

Call Klaritics.setup(config, context) once at app startup, before any other Klaritics call. The config is identical on both platforms; only the context differs. Expose a small entry point from your shared module so each platform passes its own context:
shared/src/commonMain/kotlin/Analytics.kt

KlariticsConfig

Android setup

Nothing beyond the repositories is needed; the native klaritics-android-sdk AAR is pulled transitively. Android requires the Application context:
MyApp.kt
Calling the no-arg KlariticsContext() on Android throws IllegalStateException. Always pass the Application.

iOS setup

The SDK links the native Klaritics framework via Kotlin’s SwiftPM integration, which pulls the Klaritics Swift package (binary xcframework) from github.com/deeptaai/klaritics-ios-sdk at version 1.0.0. The framework linkage propagates to your build automatically. CocoaPods is not required and you add no -framework flags yourself.
1

Emit a framework from your shared module

shared/build.gradle.kts
2

Add the generated SwiftPM linkage package to Xcode

Building for an iOS target generates a SwiftPM linkage package (KotlinMultiplatformLinkedPackage) that includes the transitive Klaritics dependency. Add that package to your Xcode app project using Kotlin’s direct SwiftPM integration. This resolves the Klaritics symbols.
3

Initialize from Swift

In your AppDelegate, call the shared entry point. The iOS context is an empty marker:
AppDelegate.swift

API reference

All methods are called on the Klaritics object (com.klaritics.kmp.Klaritics) from shared code.
Attributes are Map<String, Any?>. Entries with null values are dropped before dispatch, so both platforms send the same shape. A map that becomes empty is treated as no attributes.
“No-op” on iOS means the method is safe to call but does nothing; the native iOS SDK v1.0.0 doesn’t expose it. See Platform parity notes.

Common recipes

Log events

Identify a user and set properties

Platform parity notes

The Klaritics iOS SDK v1.0.0 exposes a smaller public surface than Android. The following methods are safe no-ops on iOS (they run normally on Android):
  • logMetaEvent
  • resetUserCustomInfo
  • resetSessionCustomInfo
  • setCurrentScreenName
  • setPushRegistrationToken
  • setDynamicConfig
  • flushEventsIfAny
  • optOut
Also, KlariticsConfig.debug and KlariticsConfig.optOut are honored on Android only. You can call these from shared code without guards; they simply do nothing on iOS. Avoid relying on them for iOS-critical behavior until the native iOS SDK adds support.

Troubleshooting

Next steps

Verify your integration

Send test events from your app and watch them land on the Getting Started page.

Event and attribute naming

Learn the naming conventions Klaritics expects for events and attributes.

Artifact: com.deeptaai.klaritics:klaritics-kmp:1.0.0 · Kotlin: 2.4.0+ · Targets: Android (minSdk 21), iOS (13.0+) · License: MIT