kmp-shared-module-architect

Designs Kotlin Multiplatform shared modules with source-set hierarchy and iOS framework export.

Updated Jan 2, 2024
One-click install
npx skills add https://github.com/Mithrandir21/game-deals-app --skill kmp-shared-module-architect-mithrandir21
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: kmp-shared-module-architect
Source: https://github.com/Mithrandir21/game-deals-app/tree/main/.claude/skills/kmp-shared-module-architect
Command: npx skills add https://github.com/Mithrandir21/game-deals-app --skill kmp-shared-module-architect-mithrandir21

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Sharing Kotlin code between Android and iOS often fails at the interop boundary: Swift developers receive unergonomic APIs with raw Flows, untranslatable generics, and broken default arguments. This Skill guides the design or refactoring of a KMP shared module so the shared code is maintainable and the iOS-facing API is idiomatic. ## Core Features & Use Cases - Source-set hierarchy design: Structures commonMain, androidMain, iosMain, and iOS variant source sets with correct Gradle configuration and dependency placement. - iOS interop shaping: Decides between SKIE and KMP-NativeCoroutines for Flow/suspend bridging, and defines rules for sealed classes, Result types, and default arguments in the public API. - Framework publishing: Configures direct Xcode integration, CocoaPods, or Swift Package Manager distribution of the iOS framework. - Use Case: A team wants to share their networking layer and repository logic between an Android app and an iOS app. The Skill produces a source-set diagram, a public API sketch with iOS-facing notes, tooling choices, and a test setup using commonTest, Turbine, and Ktor MockEngine. ## Quick Start Ask the assistant to design a Kotlin Multiplatform shared module that shares networking and repository logic between Android and iOS with SKIE enabled.

Frequently Asked Questions about kmp-shared-module-architect

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

FAQPage Schema
How do I set up a Kotlin Multiplatform shared module for Android and iOS?▼

Use the hierarchical source-set template with commonMain for shared code, androidMain for Android-specific code, and iosMain shared across iosX64, iosArm64, and iosSimulatorArm64 targets. Configure each iOS target to produce a framework binary in build.gradle.kts.

SKIE vs KMP-NativeCoroutines for Kotlin Flow in Swift?▼

SKIE transforms generated headers so Swift sees sealed classes as enums, Flows as AsyncSequence, and suspend functions as async functions, making it the default choice for new projects. KMP-NativeCoroutines is an alternative that generates Swift extensions via annotations like @NativeCoroutines.

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

Use expect/actual only for platform APIs with no common equivalent, such as logging via Logcat versus OSLog, or UUID generation. Prefer interfaces with dependency injection for non-trivial cases, since expect/actual couples implementations to the source-set tree and complicates testing.

Can I expose Kotlin Flow directly to Swift code?▼

Raw Flow and StateFlow cannot be consumed idiomatically from Swift without bridging. Use SKIE to expose Flows as AsyncSequence, or KMP-NativeCoroutines to generate completion-handler or AsyncSequence wrappers.

How do I publish a KMP framework to an iOS project?▼

Three options exist: direct Xcode integration using the embedAndSignAppleFrameworkForXcode Gradle task, CocoaPods with a generated podspec, or Swift Package Manager via kmmbridge. Direct Xcode integration is simplest for monorepos; CocoaPods or SPM suit external distribution.

What code should not go into a KMP shared module?▼

Avoid sharing UI, platform navigation, push notification handling, background work scheduling, and platform integrations like camera or biometrics. Start with networking and data models, grow toward business logic, and stop before platform-specific integrations.