Mobile KMP
БесплатноБез исполняемых скриптовНе проверенBuilds and reviews Kotlin Multiplatform and Compose Multiplatform code for Android and iOS: source sets and the default hierarchy template, interfaces with DI…
от ahmadhussain0335144 установки в других каталогахОб этом скилле
Kotlin Multiplatform
Share business logic between Android and iOS without making either app worse. A good result has a
commonMain that compiles without platform imports, platform services behind interfaces, a Swift API that
feels native, a build on the current Gradle plugins, and tests that run on every target.
When to use
- Setting up a shared KMP module, or adding iOS to an existing Android codebase.
- Moving repositories, ViewModels, networking or persistence from Android code into
commonMain. - Choosing between expect/actual and interfaces, Room KMP and SQLDelight, SKIE and KMP-NativeCoroutines, shared Compose UI and native UI.
- Fixing Swift-side pain: lost generics,
KotlinIntboxes, non-exhaustiveswitch, crashes from Kotlin exceptions, Flows that SwiftUI cannot observe. - Upgrading to AGP 9, where the KMP plugin no longer works with
com.android.applicationorcom.android.libraryin the same module. - Publishing the shared code to an iOS team as an XCFramework or Swift package.
Not for: Android-only Kotlin style (use mobile-kotlin), Swift-only code (use mobile-swift), CI pipelines
(use mobile-ci-cd), or Flutter (use mobile-flutter).
Workflow
- Read the build before writing code.
gradle/libs.versions.toml: Kotlin, AGP, Compose Multiplatform, coroutines, Ktor, Room or SQLDelight, SKIE or KMP-NativeCoroutines versions.settings.gradle.ktsand each module's plugins: whereorg.jetbrains.kotlin.multiplatformis applied and which Android plugin sits next to it.- Declared targets, framework
baseName,export(...)calls, and how Xcode consumes the framework (build-phase script, local package, CocoaPods, remote XCFramework).
- Check compatibility before adding or upgrading anything. SKIE, KSP, Room and Compose Multiplatform each
support a specific Kotlin range. Do not bump Kotlin, AGP,
compileSdkor the iOS deployment target without asking. - Load the reference for the area being touched: Structure and Gradle, iOS interop, Data and networking, Testing.
- Decide what is shared. Default: domain, data, networking, persistence and ViewModels in
commonMain; UI per Rule 13. Hardware stacks (BLE, camera, location, push) stay platform code behind an interface. - Write common code first, then platform implementations, then the Swift-facing facade.
- Add
commonTesttests for new shared logic; run them on the JVM and the iOS simulator target. - Build both apps:
./gradlew :androidApp:assembleDebugand the iOS app in Xcode (or./gradlew :shared:linkDebugFrameworkIosSimulatorArm64). A green Android build says nothing about iOS. - Report what moved to common code, new dependencies, Swift API changes, and every
Info.plist, entitlement, Gradle property or Xcode build-phase change. These need explicit sign-off.
Rules
1. Use the default hierarchy template; never wire dependsOn by hand
// BAD: manual intermediate source set, disables the default template with a warning
val iosMain by creating { dependsOn(commonMain.get()) }
iosArm64Main.get().dependsOn(iosMain)
// GOOD: iosMain, appleMain and nativeMain exist automatically for the declared targets
kotlin {
iosArm64()
iosSimulatorArm64()
sourceSets {
commonMain.dependencies { implementation(libs.kotlinx.coroutines.core) }
iosMain.dependencies { implementation(libs.ktor.client.darwin) }
}
}
- Put iOS code in
iosMain, notiosArm64Main. Per-target source sets are for rare ABI differences. iosX64(Intel simulator) is Tier 3. Declare it only if the team still builds on Intel Macs, and check that every dependency still publishes it.
2. The shared module is a library; app entry points live in app modules
// BAD: KMP plugin and the Android application plugin in one module (unsupported from AGP 9)
plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.application)
}
// GOOD: shared/build.gradle.kts
plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.kotlin.multiplatform.library)
}
kotlin {
android {
namespace = "com.example.shared"
compileSdk = 36
minSdk = 26
}
iosArm64()
iosSimulatorArm64()
}
com.android.kotlin.multiplatform.libraryhas one variant and no top-levelandroid {}block. From AGP 8.12 the target iskotlin { android { } }; older AGP uses the now-deprecatedandroidLibrary { }.MainActivityand the app manifest move to anandroidAppmodule that depends onprojects.shared. Layout and AGP 9 migration: Structure and Gradle.
3. Platform services are interfaces bound in DI; commonMain stays platform-free
// BAD: expect class for a service, Android types in shared signature
Установить Mobile KMP в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Mobile KMP?
Builds and reviews Kotlin Multiplatform and Compose Multiplatform code for Android and iOS: source sets and the default hierarchy template, interfaces with DI over expect/actual, shared AndroidX ViewModels, Ktor, Room KMP or SQLDelight, kotlinx.serialization, Flow and suspend from Swift via SKIE, Objective-C and Swift export limits, XCFramework and SPM publishing, commonTest. Use when setting up, migrating to or reviewing a KMP shared module.
Как установить скилл Mobile KMP?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Mobile KMP запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic