agentsclimarketplace

Kotlin multiplatform

Skill G1Joshi/Agent-Skills/skills/mobile/kotlin-multiplatform

Kotlin Multiplatform for shared code. Use for cross-platform.From its SKILL.md

Install
npx -y skills add G1Joshi/Agent-Skills --skill kotlin-multiplatform

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 12 stars12 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

3.8 KB, 826 tokens by cl100k_base, as published. Nobody here has run it

Kotlin Multiplatform (KMP)

Kotlin Multiplatform (KMP) allows you to share code between Android, iOS, Web, and Desktop. It emphasizes sharing logic (Business, Data, Networking) while allowing for native or shared (Compose Multiplatform) UIs.

When to Use

  • Sharing complex business logic and data layers between mobile platforms.
  • Building a "Super App" SDK to be used by other native apps.
  • Teams with strong Kotlin expertise wanting to target iOS.
  • Sharing UI code via Compose Multiplatform (stable for iOS in 2025).

Quick Start

// commonMain/kotlin/Platform.kt
interface Platform {
    val name: String
}
expect fun getPlatform(): Platform

// androidMain/kotlin/Platform.kt
actual fun getPlatform(): Platform = object : Platform {
    override val name = "Android ${android.os.Build.VERSION.SDK_INT}"
}

// iosMain/kotlin/Platform.kt
import platform.UIKit.UIDevice
actual fun getPlatform(): Platform = object : Platform {
    override val name = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
}

// commonMain/kotlin/Greeting.kt
class Greeting {
    fun greet(): String = "Hello, ${getPlatform().name}!"
}

Core Concepts

Expect / Actual

Mechanism to define an interface in common code (expect) and provide platform-specific implementations (actual) in platform modules.

Shared Module

A Gradle module usually named shared or composeApp. This compiles to an .aar for Android and a .framework (or XCFramework) for iOS.

Compose Multiplatform

Google's declarative UI framework (Jetpack Compose) ported to iOS, Web, and Desktop by JetBrains. Allows sharing UI code 100%.

Common Patterns

Ktor + Kotlinx.Serialization

Use Ktor for multiplatform networking and kotlinx.serialization for JSON parsing. Both are pure Kotlin and work on all targets.

SQLDelight / Room

Use SQLDelight or Room (KMP support active) for type-safe database access shared across platforms.

Dependency Injection (Koin)

Koin is a popular pure Kotlin dependency injection framework that works seamlessly in KMP to manage singletons and factories.

Best Practices

Do:

  • Share Business Logic, Data Models, and Networking Code.
  • Use Compose Multiplatform for UI if pixel-perfect native compliance isn't critical or for custom branded apps.
  • Use Coroutines (Flow/Suspend) for all async operations.
  • Test shared code in commonTest.

Don't:

  • Don't try to share 100% of code if it degrades the user experience.
  • Don't use Java-dependent libraries in commonMain (only pure Kotlin).
  • Don't force expect/actual usage if a library (like KMP-NativeCoroutines) can solve the bridging better.

Troubleshooting

ErrorCauseSolution
Unresolved reference in commonMainUsing platform-specific API (java.util, android.*).Use KMP-compatible libraries (kotlinx-datetime).
C-interop build errorsiOS build configuration or missing headers.Check cocoapods or framework config in build.gradle.kts.
Memory Leaks on iOSCircular references or freezing (mostly solved in new memory model).Ensure newer Kotlin version (1.9+) is used.

References

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.