Hello :wave: . What strategy are you using current...
# multiplatform
g
Hello 👋 . What strategy are you using currently to use Swift only library (like JOSESwift) in the multiplatform library? For now we cheat a bit, and we are using swift-klib-plugin, copy the Swift code into KMP lib, and add @Objc annotations to the Swift code. I wonder if there is a better way to do this? Especially that Swift import is not even on the roadmap.
p
h
Pretty straight forward using DI, but if you aren't using DI then this approach won't work.
p
The technique is not related to DI. DI helps but you can do it manually too, it's just that you have to type a bit more manual code. But in general you can pass interfaces or abstract classes implemented in swift to kotlin land with no issue. The way you handle or manage this instances on the Kotlin side is up to you. You could have a global Singleton hosting all of them. Or you could simply use global factory functions. But I agree DI containers make it easy
👍 1
g
Thanks. Interfaces and swift implementation is ok in the shared module, but not a good fit if you want to use it in the standalone library. In my case JOSESwift is an implementation detail, and forcing all apps that uses this library to provide implementation is a no go.
h
Ahh ya, fair enough. Hope you figured out a different solution!
g
sounds like this PR from the other thread is what I need as well: https://github.com/ttypic/swift-klib-plugin/pull/47
🙌 2