Closed BulatMukhutdinov closed 2 years ago
Here's an old commit that tried configure Koin from Swift. It's complicated because Koin's internals will try to pull out a KClass
and you can't do that for Objective-C types, so I had to cast things to Any
and use qualifiers to disambiguate instead. We decided this wasn't worth it which is why we instead have the current configuration where Swift dependencies are passed as function arguments and the Koin configuration happens on the Kotlin side.
I see, thanks. Then probably you can provide an example of what is the best way to provide dependencies in swift code? For example, how to provide a view model (which has dependencies from koin) created inside swift code to view.
I'd probably write a basic factory object that's easy to call from Swift. Interacting with Koin directly will be clumsy because of the generics, etc. Easier to write concrete Kotlin wrappers and call them.
You provided an example of how to fetch and use objects from a shared module using koin. But could you also provide an example of how to create koin modules directly inside iOS code on Swift and then fetch these dependenceis?
Thanks in advance