Hoping this is a good place to ask this, I just re...
# koin
a
Hoping this is a good place to ask this, I just recently read an article about Koin 3.0 hitting alpha with support for Kotlin Multiplatform which I was happy to hear since I originally started using Koin for Android. In Android, I was always used to grabbing a dependency from Koin by marking the class with
KoinComponent
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/
z
@Andrew Steinmetz I’m just working on it right now, I’m having a problem how to get KotlinKClass of object in Swift. For the testing purposes I created a fun in kotlin common just to return me the type and it seems to work lol
Copy code
let koinApp = KoinMasterKt.doInitKoin()
    let engine = koinApp.koin.get(clazz: KoinMasterKt.getEngineClassType(), qualifier: nil, parameters: nil)
In the kmp module the fun looks like this:
Copy code
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.
👍 1