expect-actual
Installation
SKILL.md
expect/actual Pattern for KMP
The expect/actual declaration is Kotlin's mechanism for writing platform-specific implementations while maintaining a shared API surface.
Core Concept
// shared/commonMain/kotlin/Platform.kt
expect class Platform() {
val name: String
}
// shared/androidMain/kotlin/Platform.android.kt
actual class Platform {
actual val name: String = "Android ${Build.VERSION.SDK_INT}"
}