Andrew Steinmetz
06/02/2020, 6:16 AMKoinComponent
interface and using the get<SomeDependency>()
function. Now that I have compiled my multiplatform project for iOS with the latest Koin dependency, I was wondering since I am new to swift if there was any equivalent to doing the same thing to grab a dependency from swift?
This was the article I found with an example which seems to use property injection and doesn't actually create the repository as a single in iOS? https://johnoreilly.dev/posts/kotlinmultiplatform-koin/zalewski.se
06/02/2020, 2:24 PMlet koinApp = KoinMasterKt.doInitKoin()
let engine = koinApp.koin.get(clazz: KoinMasterKt.getEngineClassType(), qualifier: nil, parameters: nil)
In the kmp module the fun looks like this:
fun getEngineClassType(): KClass<Engine> = Engine::class
Just keep in mind if you use multiple kmp frameworks for iOS that shared modules have different types in Swift of same class in Kotlin.