Anchor DI

Compile-time dependency injection for Kotlin Multiplatform (KMP) with first-class Compose Multiplatform support. Hilt/Dagger-like developer experience — if it compiles, it works.
What is Anchor DI?
Anchor DI is a compile-time DI framework for KMP. It uses KSP (Kotlin Symbol Processing) to analyze your annotated code and generate a static dependency graph at build time. No runtime reflection, no service locator — just generated Kotlin code that wires your dependencies.
Built for: Android, iOS, Desktop (JVM), and Web (Wasm). Same API across all platforms.
Why Anchor DI?
Anchor DI validates your dependency graph at compile time — missing bindings, cycles, and scope violations fail the build, not your app.
Quick Start
Option A: Convention Plugin (Recommended)
plugins {
id("anchor-di-convention")
}
anchorDi {
compose = true
}
Option B: Manual Setup
plugins {
id("com.google.devtools.ksp") version "2.3.5"
}
repositories { mavenCentral() }
kotlin {
sourceSets {
commonMain.dependencies {
implementation(platform("io.github.12345debdut:anchor-di-bom:1.0.0"))
implementation("io.github.12345debdut:anchor-di-api")
implementation()
implementation()
}
}
}
dependencies {
add(, )
add(, )
add(, )
add(, )
}
Define and inject
@Singleton
class UserRepository @Inject constructor(
private val api: UserApi
)
@AnchorViewModel
class UserViewModel (
repository: UserRepository
) : ViewModel()
) {
}
Initialize at startup
Anchor.init(*getAnchorContributors())
Call once in Application.onCreate() (Android), your app entry (iOS), or before the first Composable.
Installation Variants
Prerequisites: Kotlin 1.9+, KSP 2.3+, Gradle 8+
Key Features
Platforms
| Platform | Status |
|---|
| Android | Supported |
| iOS (arm64, simulator) | Supported |
Documentation
Full documentation — installation, core concepts, scopes, Compose integration, KMP setup, guides, and troubleshooting.
- Koin Migration Guide — side-by-side comparison for teams moving from Koin
- Benchmarks — performance data: Anchor DI vs Koin
- Changelog — release history
Contributing
Contributions welcome. See CONTRIBUTING.md for how to build, run tests, and contribute.
License
Apache License 2.0