kotlin-multiplatform
Kotlin Multiplatform - shared code, expect/actual, iOS integration
When & Why to Use This Skill
This Claude skill streamlines Kotlin Multiplatform (KMP) development by providing automated project configurations, boilerplate for shared codebases, and seamless iOS integration. It addresses the complexity of cross-platform mobile development by managing the expect/actual mechanism and Gradle setup, significantly reducing the time required to build and maintain synchronized Android and iOS applications.
Use Cases
- Project Initialization: Rapidly setting up KMP project structures with pre-configured Gradle scripts for Android and iOS targets.
- Platform-Specific Implementation: Generating 'expect/actual' declarations for accessing native APIs like local storage, sensors, or keychains across different operating systems.
- Dependency Management: Configuring shared Ktor or SQLDelight dependencies to ensure consistent networking and data persistence layers.
- iOS Integration & Troubleshooting: Resolving framework linking issues and automating the build tasks required to export Kotlin code to Xcode projects.
- Code Refactoring: Migrating existing platform-specific logic into a shared Kotlin module to improve maintainability and reduce code duplication.
| name | kotlin-multiplatform |
|---|---|
| description | Kotlin Multiplatform - shared code, expect/actual, iOS integration |
| version | "1.0.0" |
| sasmp_version | "1.3.0" |
| bonded_agent | 04-kotlin-multiplatform |
| bond_type | PRIMARY_BOND |
| timeout_ms | 30000 |
| max_attempts | 3 |
| backoff | exponential |
| initial_delay_ms | 1000 |
| - name | platforms |
| type | array |
| validation | "^(setup|shared|expect_actual|ios)$" |
| default | ["android", "ios"] |
| level | info |
| events | [skill_invoked, target_loaded, error_occurred] |
Kotlin Multiplatform Skill
Build cross-platform applications with shared Kotlin code.
Topics Covered
Project Setup
kotlin {
androidTarget()
listOf(iosX64(), iosArm64(), iosSimulatorArm64()).forEach {
it.binaries.framework { baseName = "Shared"; isStatic = true }
}
sourceSets {
commonMain.dependencies {
implementation("io.ktor:ktor-client-core:2.3.8")
}
androidMain.dependencies { implementation("io.ktor:ktor-client-okhttp:2.3.8") }
iosMain.dependencies { implementation("io.ktor:ktor-client-darwin:2.3.8") }
}
}
expect/actual
// commonMain
expect class SecureStorage { fun get(key: String): String? }
// androidMain
actual class SecureStorage { actual fun get(key: String) = prefs.getString(key, null) }
// iosMain
actual class SecureStorage { actual fun get(key: String) = KeychainWrapper.get(key) }
Troubleshooting
| Issue | Resolution |
|---|---|
| "No actual for expect" | Add implementation in platform source set |
| iOS framework not found | Run linkDebugFrameworkIos task |
Usage
Skill("kotlin-multiplatform")