kotlin-multiplatform

Guide Kotlin Multiplatform architecture decisions for source sets and expect/actual patterns.

10.4k|519|Updated Apr 15, 2023
One-click install
npx skills add https://github.com/maxrave-dev/SimpMusic --skill kotlin-multiplatform-maxrave-dev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-multiplatform
Source: https://github.com/maxrave-dev/SimpMusic/tree/main/.claude/skills/kmp
Command: npx skills add https://github.com/maxrave-dev/SimpMusic --skill kotlin-multiplatform-maxrave-dev

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill provides expert guidance on Kotlin Multiplatform (KMP) architecture, specifically focusing on making effective platform abstraction decisions, optimizing source set placement, and correctly implementing expect/actual patterns to maximize code sharing and maintainability across diverse platforms like Android, Desktop, and iOS.

Core Features & Use Cases

  • Abstraction Guidance: Helps decide when to abstract code versus keeping it platform-specific.
  • Source Set Strategy: Guides placement of code in commonMain, jvmAndroid, and platform-specific source sets.
  • Expect/Actual Implementation: Details the correct usage of expect/actual for platform-dependent APIs.
  • Use Case: When developing a new feature that involves cryptographic operations, this Skill helps determine whether to use expect/actual for platform-specific security APIs or if the logic can reside entirely in commonMain.

Quick Start

Use the kotlin-multiplatform skill to decide if a new ViewModel should be shared across Android and Desktop platforms.

Frequently Asked Questions about kotlin-multiplatform

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

FAQPage Schema
When should I use expect/actual declarations versus keeping code in commonMain?

Use expect/actual declarations in Kotlin Multiplatform when platform-specific APIs differ, like cryptographic operations; keep logic in commonMain only if it requires no platform-specific dependencies.

How do I decide source set placement between commonMain and jvmAndroid in Kotlin Multiplatform?

Place shared code in commonMain for all targets, and use jvmAndroid source sets to share logic exclusively between Android and JVM platforms, optimizing structural validation and dependency management.

Does this Skill guide build.gradle.kts configurations for KMP dependency management?

Yes, it integrates with build.gradle.kts configurations to validate structural dependencies and manage source set placement across Android, JVM, and iOS targets in Kotlin Multiplatform projects.

What is the best way to share a ViewModel across Android and Desktop platforms using KMP?

The best way is to evaluate platform abstractions in Kotlin Multiplatform, deciding whether to place shared ViewModel logic in commonMain or use intermediate source sets for Android and Desktop.

How do I handle platform abstraction for security APIs across Android, JVM, and iOS?

Implement platform abstraction for security APIs using expect/actual patterns, defining expected declarations in commonMain and actual implementations for Android, JVM, and iOS source sets.