Kotlin Multiplatform Project Design
Share Kotlin domain logic between Android and iOS, select source sets and platform adapters, and verify both host applications against the same behavior contract.
Select a small vertical slice whose behavior can be tested without either UI, such as parsing a domain record or deciding whether offline data is stale. Identify what must remain platform-owned: permission prompts, filesystem, secure storage, OS lifecycle and any native presentation. Keep existing Android and iOS entry points unless sharing UI is part of the request. ## Key Points - [Kotlin Multiplatform source set structure](https://kotlinlang.org/docs/multiplatform/multiplatform-discover-project.html) - [Kotlin expect and actual declarations](https://kotlinlang.org/docs/multiplatform/multiplatform-expect-actual.html) - [Kotlin recommended project structure](https://kotlinlang.org/docs/multiplatform/multiplatform-project-recommended-structure.html)
skilldb get android-kotlin-skills/kotlin-multiplatformFull skill: 29 linesKotlin Multiplatform Project Design
Select a small vertical slice whose behavior can be tested without either UI, such as parsing a domain record or deciding whether offline data is stale. Identify what must remain platform-owned: permission prompts, filesystem, secure storage, OS lifecycle and any native presentation. Keep existing Android and iOS entry points unless sharing UI is part of the request.
Define the source-set and API boundary
Put portable domain models, logic and interfaces in commonMain and portable behavioral tests in commonTest. Keep Android and Apple-only dependencies in appropriate platform source sets. Verify which device and simulator targets depend on iosMain in the configured hierarchy. A dependency that compiles under Android or JVM may not publish a compatible native artifact. Read resolved Gradle targets and dependencies rather than assuming source-set names guarantee support.
Prefer injecting an interface when you need multiple implementations or simple fakes. Use expect/actual when a narrow common declaration genuinely needs platform implementations. Keep its signature portable. For example, a common freshness rule can consume an injected clock and a simple timestamp model while hosts own lifecycle and storage. Avoid wrapping entire host SDKs behind expect/actual just to claim sharing. Choose and record the team's existing framework or package integration with Xcode, including the build task and artifacts each target consumes.
Exercise both host applications
Build common and platform tests and build the Android app plus the iOS host with an appropriate Mac and Xcode. Exercise the native simulator target and actual device target when required. Run the same data cases through both public host entry points; a common test pass cannot establish Swift interop or host configuration. Add platform tests for any permissions, lifecycle or I/O that remain outside shared code.
Check API naming, nullability, error translation, cancellation, thread ownership and lifecycle at the Swift and Android boundaries. Preserve a useful failure when the platform adapter is unavailable. Verify clean CI checkout and dependency resolution on both toolchains. Keep the sharing decision reversible: move only the small verified slice first, preserve host behavior, and record unsupported targets explicitly.
References and rights
- Kotlin Multiplatform source set structure
- Kotlin expect and actual declarations
- Kotlin recommended project structure
Original SkillDB instructions under LicenseRef-SkillDB-Content. References were checked 2026-11-13 and used for technical verification.
Install this skill directly: skilldb add android-kotlin-skills
Related Skills
Navigation
Jetpack Navigation component for type-safe in-app navigation and deep linking in Android
Trace Android App Performance with Perfetto
Capture comparable Android system traces and use Perfetto to investigate startup latency, app rendering, jank, and scheduling delays.
Verify R8 and ProGuard Release Optimization
Diagnose minification and shrinking problems in Android release builds, write narrow keep rules, and verify the exact optimized artifact and its mapping.
Retrofit
Retrofit HTTP client for type-safe REST API communication in Android with Kotlin coroutines
Room Database
Room persistence library for local SQLite database access with compile-time query verification in Android
Testing
Android testing with JUnit5 for unit tests and Espresso/Compose testing for UI verification