com.deeptaai.klaritics:klaritics-kmp:1.0.0
Requirements
You need an App ID and a Host URL from the Klaritics dashboard.
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’ssettings.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’scommonMain, not per platform:
shared/build.gradle.kts
-android, -iosarm64, -iosx64, -iossimulatorarm64).
Initialize the SDK
CallKlaritics.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 nativeklaritics-android-sdk AAR is pulled transitively. Android requires the Application context:
MyApp.kt
iOS setup
The SDK links the native Klaritics framework via Kotlin’s SwiftPM integration, which pulls the Klaritics Swift package (binary xcframework) fromgithub.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 theKlaritics 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.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):logMetaEventresetUserCustomInforesetSessionCustomInfosetCurrentScreenNamesetPushRegistrationTokensetDynamicConfigflushEventsIfAnyoptOut
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