Hello, I have a pet project that I'm using to learn KMP, it's a basic Android/iOS app with a
shared
module in charge of the network part using Koin
4.0.1
for DI, Android is working ok, but iOS is throwing this error message:
Copy code
shared.KoinInitHelper#initKoin(){}. The file path does not exist on the file system: /<compiler-generated>
Not sure why the error happens, any idea how to solve this? code in ๐งต
Alejandro Rios
03/21/2025, 12:45 PM
I have this class in
iosMain
Copy code
class KoinInitHelper : KoinComponent {
private val appCoroutineDispatchers: AppCoroutineDispatchers by inject()
private val repository: DogRepository by inject()
fun appCoroutineDispatchers(): AppCoroutineDispatchers = appCoroutineDispatchers
fun dogRepository(): DogRepository = repository
fun initKoin() {
startKoin {
modules(sharedDomainModule, sharedNetworkModule)
}
}
}
Alejandro Rios
03/21/2025, 12:48 PM
and this in the main view of the iOS app:
Copy code
import SwiftUI
import Shared
@main
struct dogifyApp: App {
init() {
KoinInitHelper().doInitKoin()
}
var body: some Scene {
WindowGroup {
HomeView()
}
}
}
I also tried leaving the
initKoin
method outside the class and calling that with
KoinInitHelperKt.doInitKoin()
but I'm getting the same error
Alejandro Rios
03/24/2025, 11:10 PM
Already fixed, the issue was that I was using a wrong version of Kotlin ๐