kmp-di

Configure Koin dependency injection across Kotlin Multiplatform common and platform modules.

61|17|Updated Feb 2, 2026
One-click install
npx skills add https://github.com/ahmed3elshaer/everything-claude-code-mobile --skill kmp-di
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kmp-di
Source: https://github.com/ahmed3elshaer/everything-claude-code-mobile/tree/main/skills/kmp-di
Command: npx skills add https://github.com/ahmed3elshaer/everything-claude-code-mobile --skill kmp-di

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cross-platform Kotlin Multiplatform projects often struggle with consistent dependency injection across shared and platform-specific code. This Skill provides a Koin-based DI setup that unifies injection for common code and Android/iOS targets, reducing boilerplate and improving testability.

Core Features & Use Cases

  • Koin Multiplatform setup across commonMain, androidMain, and iosMain with shared modules.
  • Platform-specific modules for Android and iOS to provide context, platform services, and DI wiring.
  • Manual DI patterns for testing and flexible composition, enabling easy swapping of implementations.
  • Use Case: Build a shared Repository and ViewModel graph that seamlessly injects dependencies on both Android and iOS.

Quick Start

  1. Add the Koin dependencies to your shared and platform modules as shown in the examples.
  2. Define modules in commonMain and wire platform modules in androidMain/iosMain startup code; initialize Koin during app startup.
  3. Inject dependencies in UI components using koinViewModel() on Android or equivalent screen models in multiplatform code.

Frequently Asked Questions about kmp-di

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

FAQPage Schema
How do I set up dependency injection across Android and iOS in Kotlin Multiplatform?

Dependency injection in Kotlin Multiplatform uses Koin to unify injection across shared and platform-specific code. Define modules in commonMain, then wire platform-specific modules in androidMain and iosMain startup code, initializing Koin during app launch to inject ViewModels and repositories consistently on both platforms.

Can I use Koin for multiplatform projects with shared repositories and ViewModels?

Yes. Koin supports multiplatform setup where you define shared repository and ViewModel graphs in commonMain, then inject them platform-specifically using koinViewModel() on Android or equivalent patterns in iOS, eliminating boilerplate across targets.

What's the best way to handle platform-specific dependencies in a Kotlin Multiplatform app?

Create separate Koin modules for androidMain and iosMain to inject platform services and context. This approach isolates platform-specific wiring while keeping shared business logic in commonMain, improving modularity and testability.

How do I test Kotlin Multiplatform code with manual dependency injection patterns?

Manual DI patterns in Koin enable flexible composition and easy swapping of implementations for testing. Inject mock repositories and services manually during test setup without modifying production Koin configuration, supporting both unit and integration tests.

Do I need to configure Koin separately for commonMain, androidMain, and iosMain modules?

Yes. Define shared Koin modules in commonMain for common code, then configure platform-specific modules in androidMain and iosMain to provide context and platform services, combining them during app initialization for unified injection.