Hi, has anyone used Koin with ViewModels in Compos...
# multiplatform
d
Hi, has anyone used Koin with ViewModels in Compose Multiplatform? All examples and even Koin official docs say that dependency
io.insert-koin:koin-compose-viewmodel
should be in the
commonMain
source set but for some reason the build fails with the below error
Copy code
KMP Dependencies Resolution Failure
Source set ‘appleMain’ couldn’t resolve dependencies for all target platforms
Couldn’t resolve dependency ‘io.insert-koin:koin-compose-viewmodel’ in ‘appleMain’ for all target platforms.
The dependency should target platforms: [iosArm64, iosSimulatorArm64]
Unresolved platforms: [iosArm64, iosSimulatorArm64]
Run the build with ‘--info’ for more details.
Solution: Make sure you are using a dependency that targets all required platforms or move your dependency and relevant code to a more applicable source set: <https://kotl.in/57b2-source-set-dependencies>
j
That's strange, I have it in
commonMain
and it works as expected.
d
which Koin version are you using ?
This is the entire stacktrace, I’ve gone mad
j
I use koin-bom "4.1.1"
d
yeah, the same
can you share the gradle file so that I can compare if you want ?
Screenshot 2025-12-02 at 14.12.45.png
j
Copy code
kotlin {
    sourceSets {
        androidMain.dependencies {
            ...
        }
        commonMain.dependencies {
            implementation(projects.shared)
            implementation(project.dependencies.platform(libs.koin.bom))

            implementation(libs.koin.compose)
            implementation(libs.koin.compose.viewmodel)
            implementation(libs.koin.core)
        }
        iosMain.dependencies {
            ...
        }
        commonTest.dependencies {
            ...
        }
    }
}
That's my redacted
sourceSets
d
yeah, thanks, I’m interested in Koin
j
looks like you're using an alpha version
d
but Koin also use 4.2.0-alpha03 in their code sample 😄
which AGP version are you on ?
j
Copy code
"8.11.1"
d
i use
8.13.1
and they also use it
let me revert and see what happens
i read somewhere some conflicting dependency may cause this
which Kotlin version are you on ?
j
Copy code
"2.2.21"
d
why on Earth is failing for me, lol
j
😬 beats me
d
do you have gradle.properties set to bypass this ?
j
Did you clean and re-sync the project? Maybe it's a caching issue
d
let me try that as well, i did restart the studio with invalidate caches 2 times
j
🤔 strange indeed
d
no way
./gradlew clean
actually worked
my god, Gradle is such a mess
j
😮‍💨
Nice!
d
Jesus Christ..
thank you
j
You're welcome! Good luck with your project
d
ah, it doesn’t work on iOS again, haha
Android started
oh it went through, some issue with the Studio, ok nvm 😄
👍 1
thanks again
I resolved it, thanks for the assist. It was crazy f up with the dependencies. It’s brand new project so these things are crazy, luckily i found out what it was
👍 1