Hey, I have trouble with Koin and iOS. I init Koin on startup (in iOSApp#init) but when I call injec...
l
Hey, I have trouble with Koin and iOS. I init Koin on startup (in iOSApp#init) but when I call inject later I have : KoinApplication has not been started. Do you have any idea why I have this error?
👀 1
a
You have to call init koin when your application starts up. The lifecycle is a little awkward. I use to init it in the app delegate, but the initial screen UI seems to load before that often so I know call it on our App Screen where the window scene is when it appears. I don't think it matters but I also make sure it doesn't get called twice. Take a look here: https://github.com/InsertKoinIO/hello-kmp/blob/main/iosApp/iosApp/iOSApp.swift And here for the help class to init koin: https://github.com/InsertKoinIO/hello-kmp/blob/main/shared/src/iosMain/kotlin/com/example/helloworldkmp/Helper.kt
m
You may want to ask at #koin.
361 Views