https://kotlinlang.org logo
Title
s

Stefan de Kraker

05/02/2023, 1:19 PM
How can I inject a
actual
class with Koin? I have:
fun initKoin(appDeclaration: KoinAppDeclaration = {}) {
    startKoin {
        appDeclaration()
        modules(datamodule, domainModule, presentationModule, platformModule)
    }
}
// commonMain
expect val platformModule: Module
// iosMain
actual val platformModule = module {
    single { StorageRepository() }
}

// storageRepository
internal actual class StorageRepository: KoinComponent { 
   ... code to store key value use sharedpref and userdefault
}
But in my swift project I cant use
storageRepository
What is wrong?
a

arnaud.giuliani

05/09/2023, 4:50 PM
you to inject it into a class you can instantiate in iOS. Take a look at this tutorial: https://insert-koin.io/docs/quickstart/kmm