-
Notifications
You must be signed in to change notification settings - Fork 2
app intents SETUP
io.github.mobilebytelabs:cmp-app-intents:3.2.11
cmp-app-intents requires 4 steps: add dependency, opt in, call AppIntents.register() at
app startup, and (iOS only) install the Swift bridge into your Xcode target.
[versions]
cmp-app-intents = "3.2.11"
[libraries]
cmp-app-intents = { module = "io.github.mobilebytelabs:cmp-app-intents", version.ref = "cmp-app-intents" }commonMain.dependencies {
implementation(libs.cmp.app.intents)
}@OptIn(ExperimentalAppIntentsApi::class)
fun initIntents() {
AppIntents.register(appIntents { /* ... */ })
}// shared/build.gradle.kts
kotlin {
compilerOptions {
freeCompilerArgs.addAll(
"-opt-in=com.mobilebytelabs.kmptoolkit.appintents.ExperimentalAppIntentsApi"
)
}
}Call AppIntents.register(...) from your shared App() init path (e.g. in
application {} block or App.kt init block):
@OptIn(ExperimentalAppIntentsApi::class)
fun initApp() {
AppIntents.register(
appIntents {
intent("open_search") {
title("Search Products")
param("query") { type = ParamType.String }
handler { params ->
val q = params["query"] as? String ?: ""
navigator.navigateToSearch(q)
AppIntentResult.Done
}
}
intent("show_dashboard") {
title("Open Dashboard")
handler { AppIntentResult.Done }
}
intent("get_balance") {
title("Get Account Balance")
handler {
val balance = repository.getBalance()
AppIntentResult.Snippet("Balance: $balance")
}
}
}
)
}@OptIn(ExperimentalAppIntentsApi::class)
suspend fun testIntent() {
val result = AppIntents.invokeForTesting(
id = "get_balance",
params = emptyMap()
)
println(result) // AppIntentResult.Snippet("Balance: ...")
}The Kotlin side writes a manifest JSON; the Swift bridge consumes it at app launch
to (a) wire the Kotlin↔Swift callback for @AppIntent.perform() bodies and
(b) push searchable intents into iOS Spotlight via CSSearchableIndex.
- Copy
cmp-app-intents/swift/CmpAppIntentBridge.swiftinto youriosAppXcode target (File → Add Files to "iosApp"). Add theCoreSpotlight.frameworkto your target's "Frameworks, Libraries, and Embedded Content" list. - Bootstrap the bridge at app launch — SwiftUI:
import SwiftUI @main struct MyApp: App { init() { CmpAppIntentBridge.shared.bootstrap { // Return the @ObjCName-exposed Kotlin singleton. // Replace `kmptoolkit` with your Kotlin/Native framework alias. return CmpAppIntentsCallback.shared } } var body: some Scene { WindowGroup { ContentView() } } }
- (Optional) Handle Spotlight item taps so users land in the right screen:
Add each
ContentView() .onContinueUserActivity("\(CmpAppIntentBridge.activityPrefix).openTransfer") { activity in _ = CmpAppIntentBridge.shared.handleContinue(activity) }
<CmpAppIntentBridge.activityPrefix>.<intent-id>you support to your Info.plistNSUserActivityTypesarray. - Copy
cmp-app-intents/swift/templates/AppIntentStub.swift.templateonce per intent you declared in Kotlin, substitute${INTENT_ID}/${PARAMS_BLOCK}/${PARAMS_DICT}, add to yourAppShortcutsProvider.appShortcutsarray. Xcode's@AppIntentmacro handles SiriKit registration automatically (iOS 16+ / macOS 13+).
macOS: same process — copy
CmpAppIntentBridge.swiftinto yourmacosApptarget.CoreSpotlightis also available on macOS 10.13+, so searchable intents work identically.
On Android, cmp-app-intents generates shortcuts.xml during the build. No manual step
is required; the Gradle plugin adds the <meta-data> entry to your merged AndroidManifest.xml
automatically.
| Platform | Behaviour |
|---|---|
| Android | On-device registry via App Actions; shortcuts.xml auto-generated at build time |
| iOS / macOS | Manifest JSON written by Kotlin; CmpAppIntentBridge.bootstrap() consumes it — wires the Kotlin↔Swift callback, indexes searchable: true intents into Spotlight via CSSearchableIndex, exposes handleContinue(_:) for tap-to-resume |
| JVM / JS / wasmJs |
invokeForTesting only — no OS integration |
/sync-app-intents # Verify Gradle dependency (only gate needed)
/sync-app-intents --check # Dry run — show status, no writes
See CLAUDE_AI_SETUP.md for full docs.
** Partials**
App Intents
Bubble
Clipboard
Cookbook
- Clipboard Copy Text
- Clipboard Read Text
- Consumer Anon Key Setup
- Crashlytics Attribution Per Library
- Ifonline Block
- Index
- Index
- Index
- Index
- Open Url Compose
- Pick And Share Image
- React To Offline
- Register Firebase Hooks
- Share Pdf Android
- Share Text
- Wifi Vs Cellular
Firebase Analytics
In App Update
Intent Launcher
Inter App Comms
Modules
- Cmp App Intents
- Cmp App Intents Compose
- Cmp Bubble
- Cmp Clipboard
- Cmp Deep Link
- Cmp Firebase Analytics
- Cmp In App Update
- Cmp Intent Launcher
- Cmp Intent Launcher Compose
- Cmp Library
- Cmp Network Monitor
- Cmp Network Monitor Compose
- Cmp Observe
- Cmp Observe Koin
- Cmp Open Url
- Cmp Pdf Generator
- Cmp Product Tickets
- Cmp Remote Config
- Cmp Share
- Cmp Share Compose
- Cmp Toast
Network Monitor
Open Url
Pdf Generator
Remote Config
Share
Toast
User Tickets
General