
Remotely-configurable in-app paywall: unified API to configure, register placements, observe subscription-status flows, and bridge native SDKs via a native bridge.
Kotlin Multiplatform SDK for Superwall — remotely configurable in-app paywall infrastructure.
This library wraps the native SuperwallKit SDKs (Android and iOS) behind a single Kotlin Multiplatform API. The public API lives entirely in commonMain — no platform types, and an identical configure signature on both platforms (no Context parameter on Android).
One Gradle dependency — the native superwall-android SDK is bundled transitively, and an androidx.startup initializer captures the Application automatically:
// build.gradle.kts (commonMain or androidMain dependencies)
implementation("com.superwall.sdk:superwall-kmp:<version>")Two steps (iOS 15+, built with Xcode 26 or later):
Add the same Gradle dependency (above) to your shared module, and export the framework as static:
// shared module build.gradle.kts
listOf(iosArm64(), iosSimulatorArm64(), iosX64()).forEach {
it.binaries.framework {
baseName = "Shared"
isStatic = true // required — the Kotlin framework does not embed the bridge binary
}
}Add the SuperwallKMPBridge Swift package to your iOS app via SPM, using this repository's URL:
https://github.com/superwall/Superwall-KMP
In Xcode: File → Add Package Dependencies… → paste the URL → add the SuperwallKMPBridge product to your app target. The package pins SuperwallKit iOS (exact 4.19.1) transitively — do not add SuperwallKit separately.
The Kotlin side compiles against the bridge's ObjC headers only (compile-only cinterop); your app supplies the binary by linking the SPM package. If it is missing you'll get a link error at app build time, not at runtime.
import com.superwall.sdk.kmp.Superwall
import com.superwall.sdk.kmp.models.entitlements.SubscriptionStatus
import kotlinx.coroutines.launch
// 1. Configure as early as possible (suspend twin: Superwall.configureAndAwait(...))
Superwall.configure(apiKey = "pk_your_api_key") { result ->
result.onFailure { println("Superwall configuration failed: $it") }
}
// 2. Register a placement to gate a feature behind a paywall
Superwall.register(placement = "campaign_trigger") {
// Feature code — runs per the paywall's feature-gating behavior
launchTheFeature()
}
// 3. Observe subscription status (collectable even before configure;
// seeded with SubscriptionStatus.Unknown, delivered on your collecting scope)
scope.launch {
Superwall.subscriptionStatusFlow.collect { status ->
when (status) {
is SubscriptionStatus.Active -> showPro(status.entitlements)
is SubscriptionStatus.Inactive -> showFree()
is SubscriptionStatus.Unknown -> showLoading()
}
}
}Superwall.getPaywall returns an EmbeddedPaywall that common code can hold and release. The thing to put on screen is a platform object, read through one accessor per platform: paywall.view on Android and paywall.viewController on iOS.
// commonMain
val callback = object : PaywallViewCallback {
override fun onFinished(paywallInfo: PaywallInfo, result: PaywallResult, shouldDismiss: Boolean) {
if (shouldDismiss) closePaywallScreen()
}
override fun onSkip(reason: PaywallSkippedReason) = closePaywallScreen()
override fun onError(error: String) = closePaywallScreen()
}
val paywall: EmbeddedPaywall? = Superwall.getPaywall("campaign_trigger", callback = callback) // null: skipped or failed// androidMain
AndroidView(factory = { paywall.view }, onRelease = { paywall.destroy() })// iosMain
UIKitViewController(factory = { paywall.viewController }, modifier = Modifier.fillMaxSize())
DisposableEffect(paywall) { onDispose { paywall.destroy() } }An expect/actual composable in your app (@Composable expect fun PaywallHost(paywall: EmbeddedPaywall)) can wrap the two, so your screens stay in common code. Always call destroy() when you are done with a paywall. On Android that is what ends the presentation; removing the view isn't enough.
A few other members take platform objects and are declared the same way, in the Android or iOS source set: the Play Billing overloads of observePurchaseStart / observePurchaseError / observePurchaseResult and dispatchKeyEvent / dispatchMotionEvent on Android, and gamepadValueChanged, presentedViewController and customerCenterViewController on iOS.
There is no pre-configure call queue: most members throw SuperwallError.NotConfigured before configure. Use configureAndAwait or gate on Superwall.isConfigured to order calls. Guard-exempt: handleDeepLink, the flows, delegate, and the introspection properties.
minSdk 26, matching the native superwall-android SDK)iosArm64, iosSimulatorArm64, iosX64), built with Xcode 26 or later# Build the library
./gradlew :superwall-kmp:build
# Run tests (common + Android host tests; iOS simulator tests on macOS)
./gradlew :superwall-kmp:allTests
# Lint
./gradlew :superwall-kmp:check
# Swift bridge tests (macOS only). NOT `swift test` — bridge/Package.swift is
# iOS-only, so a host build fails on SuperwallKit's `import UIKit`.
cd bridge && xcodebuild test -scheme SuperwallKMPBridge \
-workspace . -destination 'platform=iOS Simulator,name=iPhone 17'
# Build the bridge XCFramework (macOS only)
./bridge/scripts/build-xcframework.shThe public Superwall facade (superwall-kmp/src/commonMain/.../Superwall.kt) is a thin layer over an internal SuperwallBridge interface with one platform actual each:
androidMain) wraps com.superwall.sdk:superwall-android directly.iosMain) forwards through SuperwallKMPBridge (bridge/), a self-authored @objc Swift facade over SuperwallKit that destructures Swift-only constructs (enum associated values, structs, async) into ObjC-visible envelopes, consumed via cinterop.For details:
.agents/AGENTS.md — architecture, repo layout, build/test commands, conventions, and the release processdocs/MODELS.md — the public model typesApache License 2.0 — see LICENSE.
Kotlin Multiplatform SDK for Superwall — remotely configurable in-app paywall infrastructure.
This library wraps the native SuperwallKit SDKs (Android and iOS) behind a single Kotlin Multiplatform API. The public API lives entirely in commonMain — no platform types, and an identical configure signature on both platforms (no Context parameter on Android).
One Gradle dependency — the native superwall-android SDK is bundled transitively, and an androidx.startup initializer captures the Application automatically:
// build.gradle.kts (commonMain or androidMain dependencies)
implementation("com.superwall.sdk:superwall-kmp:<version>")Two steps (iOS 15+, built with Xcode 26 or later):
Add the same Gradle dependency (above) to your shared module, and export the framework as static:
// shared module build.gradle.kts
listOf(iosArm64(), iosSimulatorArm64(), iosX64()).forEach {
it.binaries.framework {
baseName = "Shared"
isStatic = true // required — the Kotlin framework does not embed the bridge binary
}
}Add the SuperwallKMPBridge Swift package to your iOS app via SPM, using this repository's URL:
https://github.com/superwall/Superwall-KMP
In Xcode: File → Add Package Dependencies… → paste the URL → add the SuperwallKMPBridge product to your app target. The package pins SuperwallKit iOS (exact 4.19.1) transitively — do not add SuperwallKit separately.
The Kotlin side compiles against the bridge's ObjC headers only (compile-only cinterop); your app supplies the binary by linking the SPM package. If it is missing you'll get a link error at app build time, not at runtime.
import com.superwall.sdk.kmp.Superwall
import com.superwall.sdk.kmp.models.entitlements.SubscriptionStatus
import kotlinx.coroutines.launch
// 1. Configure as early as possible (suspend twin: Superwall.configureAndAwait(...))
Superwall.configure(apiKey = "pk_your_api_key") { result ->
result.onFailure { println("Superwall configuration failed: $it") }
}
// 2. Register a placement to gate a feature behind a paywall
Superwall.register(placement = "campaign_trigger") {
// Feature code — runs per the paywall's feature-gating behavior
launchTheFeature()
}
// 3. Observe subscription status (collectable even before configure;
// seeded with SubscriptionStatus.Unknown, delivered on your collecting scope)
scope.launch {
Superwall.subscriptionStatusFlow.collect { status ->
when (status) {
is SubscriptionStatus.Active -> showPro(status.entitlements)
is SubscriptionStatus.Inactive -> showFree()
is SubscriptionStatus.Unknown -> showLoading()
}
}
}Superwall.getPaywall returns an EmbeddedPaywall that common code can hold and release. The thing to put on screen is a platform object, read through one accessor per platform: paywall.view on Android and paywall.viewController on iOS.
// commonMain
val callback = object : PaywallViewCallback {
override fun onFinished(paywallInfo: PaywallInfo, result: PaywallResult, shouldDismiss: Boolean) {
if (shouldDismiss) closePaywallScreen()
}
override fun onSkip(reason: PaywallSkippedReason) = closePaywallScreen()
override fun onError(error: String) = closePaywallScreen()
}
val paywall: EmbeddedPaywall? = Superwall.getPaywall("campaign_trigger", callback = callback) // null: skipped or failed// androidMain
AndroidView(factory = { paywall.view }, onRelease = { paywall.destroy() })// iosMain
UIKitViewController(factory = { paywall.viewController }, modifier = Modifier.fillMaxSize())
DisposableEffect(paywall) { onDispose { paywall.destroy() } }An expect/actual composable in your app (@Composable expect fun PaywallHost(paywall: EmbeddedPaywall)) can wrap the two, so your screens stay in common code. Always call destroy() when you are done with a paywall. On Android that is what ends the presentation; removing the view isn't enough.
A few other members take platform objects and are declared the same way, in the Android or iOS source set: the Play Billing overloads of observePurchaseStart / observePurchaseError / observePurchaseResult and dispatchKeyEvent / dispatchMotionEvent on Android, and gamepadValueChanged, presentedViewController and customerCenterViewController on iOS.
There is no pre-configure call queue: most members throw SuperwallError.NotConfigured before configure. Use configureAndAwait or gate on Superwall.isConfigured to order calls. Guard-exempt: handleDeepLink, the flows, delegate, and the introspection properties.
minSdk 26, matching the native superwall-android SDK)iosArm64, iosSimulatorArm64, iosX64), built with Xcode 26 or later# Build the library
./gradlew :superwall-kmp:build
# Run tests (common + Android host tests; iOS simulator tests on macOS)
./gradlew :superwall-kmp:allTests
# Lint
./gradlew :superwall-kmp:check
# Swift bridge tests (macOS only). NOT `swift test` — bridge/Package.swift is
# iOS-only, so a host build fails on SuperwallKit's `import UIKit`.
cd bridge && xcodebuild test -scheme SuperwallKMPBridge \
-workspace . -destination 'platform=iOS Simulator,name=iPhone 17'
# Build the bridge XCFramework (macOS only)
./bridge/scripts/build-xcframework.shThe public Superwall facade (superwall-kmp/src/commonMain/.../Superwall.kt) is a thin layer over an internal SuperwallBridge interface with one platform actual each:
androidMain) wraps com.superwall.sdk:superwall-android directly.iosMain) forwards through SuperwallKMPBridge (bridge/), a self-authored @objc Swift facade over SuperwallKit that destructures Swift-only constructs (enum associated values, structs, async) into ObjC-visible envelopes, consumed via cinterop.For details:
.agents/AGENTS.md — architecture, repo layout, build/test commands, conventions, and the release processdocs/MODELS.md — the public model typesApache License 2.0 — see LICENSE.