Join Slack
Menu
Home
Archive
Hey, I have trouble with Koin and iOS. I init Koin on startup (in iOSApp#init) but when I call injec...
# multiplatform
l
Louis
03/28/2023, 12:52 PM
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
Anonymike
03/28/2023, 2:53 PM
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
Marcello Galhardo
03/28/2023, 9:12 PM
You may want to ask at
#koin
.
361
Views
Open in Slack
Previous
Next
kotlinlang
A modern programming language that makes developers happier.
Powered by