# koin

Osman Saral

12/01/2023, 9:03 PM
Hi, is it possible to create definitions from the Swift side somehow? I mean something like that:
Copy code
let iosModule = module {
   $0.single { Foo() }
   $0.single(named("BASE_URL")) { Config.BASE_URL }
   $0.factory { Bar(get()) }

initKoin {
If it's not possible, are there any workarounds? (On my use case, I need to add BASE_URL from a xcconfig file configuration. Maybe I can find another way to do this but I would like to do what I did on Android side using buildConfig fields)


12/02/2023, 2:22 AM
Check the touchlab samples. I think KampKit was the one with such an example. The approach is that you define an object on the Kotlin side, say,
with something like this:
Copy code
getBaz(nameQualifier: String): Baz = getKoin().get<Baz>(named(qualifier))
And on Swift side where you need an instance, you call it like
Copy code
So you still define all modules on the Kotlin side. But you can still pass dependencies from the Swift side.

Osman Saral

12/04/2023, 8:10 AM
I'm actually using KaMPKit but it's not what I want. This still requires Baz to be defined in kotlin side. I want to define Baz in Swift side. What you shared is just a way to get a dependency with another function. It doesn't create a definition from swift side, it only injects dependency "to" the swift side.
👍🏽 1
there is an open issue on github about this