kotlin-multiplatform

Structure Kotlin Multiplatform source sets across Android, Desktop, and iOS with expect/actual patterns.

1.6k|218|Updated Jan 11, 2023
One-click install
npx skills add https://github.com/vitorpamplona/amethyst --skill kotlin-multiplatform
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-multiplatform
Source: https://github.com/vitorpamplona/amethyst/tree/main/.claude/skills/kotlin-multiplatform
Command: npx skills add https://github.com/vitorpamplona/amethyst --skill kotlin-multiplatform

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Platform abstraction and source-set decisions for Amethyst Kotlin Multiplatform project. Guides when to abstract vs keep platform-specific, source set placement (commonMain, jvmAndroid, platform-specific), expect/actual patterns. Covers primary targets (Android, JVM/Desktop, iOS) with web/wasm future considerations. Integrates with Gradle and dependency management.

Core Features & Use Cases

  • Guidance on crypto, IO, and platform APIs separation using expect/actual with decision trees and examples from Amethyst.
  • Real-world strategies for source-set layout, module boundaries, and migration paths; includes examples and potential pitfalls.
  • Use Case: when starting a new KMP module, determine whether to place code in commonMain or a platform-specific source set, and how to arrange cross-target dependencies and dependencies between source sets.

Quick Start

Review the Abstraction Decision Tree and begin migrating shared logic into commonMain where applicable.

Frequently Asked Questions about kotlin-multiplatform

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure Kotlin Multiplatform source sets for Android, Desktop, and iOS?

To structure Kotlin Multiplatform source sets, place shared logic in commonMain and use intermediate source sets like jvmAndroid to optimize sharing across Android, Desktop, and iOS targets. Apply correct source-set ordering and Gradle configuration to manage dependencies.

When should I use expect/actual patterns in Kotlin Multiplatform?

Use expect/actual patterns in Kotlin Multiplatform when abstracting platform-specific APIs for crypto, IO, and compatibility logic. Apply an abstraction decision tree to determine whether to place code in commonMain or keep it platform-specific in androidMain, jvmMain, or iosMain.

What is the best way to migrate shared logic into a new KMP module?

The best way to migrate shared logic into a new KMP module involves reviewing an Abstraction Decision Tree to determine source set placement, then progressively moving applicable code into commonMain while arranging cross-target dependencies and module boundaries.

Does Kotlin Multiplatform support sharing code between JVM and Android targets?

Yes, Kotlin Multiplatform supports sharing code between JVM and Android targets by utilizing the jvmAndroid source set. This intermediate source set allows you to share logic between androidMain and jvmMain before diverging into platform-specific implementations.

What are common pitfalls when configuring Gradle source sets for KMP?

Common pitfalls when configuring Gradle source sets for KMP include incorrect source-set ordering and improper arrangement of dependencies between source sets. Real-world strategies help avoid these issues by defining clear module boundaries and migration paths.