https://kotlinlang.org logo
l

Laxman Sahni

04/26/2022, 2:36 PM
Can I consume multiple dynamic Kotlin/Native frameworks in a single iOS application?
We would like to create multiple dynamic Kotlin/Native frameworks for different purposes & consume in a iOS app through Swift Package Manager. If it's supported, we can host these artifacts on our artifacts repository & consume through
Swift Package Manager
.
m

mkrussel

04/26/2022, 2:57 PM
l

Laxman Sahni

04/26/2022, 5:25 PM
@mkrussel This article https://stackoverflow.com/questions/67403200/how-to-generate-a-framework-depending-from-another-with-kotlin-native/67403855#67403855 also points in same direction. I've impression it's supported since 1.3.70. Now we've Kotlin 1.6.21 which would be much better. However, I'm still open for inputs if something better ways are exposed in latest version.
k

kpgalligan

04/26/2022, 6:40 PM
The blog post is old, but not a whole lot has changed (and likely won’t). You can have multiple frameworks in the same app. They cannot communicate with each other. They might share the same dependencies, but those dependencies are distinct at a binary level. So if you had a “Products” framework and a “Taxes” framework, you couldn’t pass a product class instance from “Products” to “Taxes”, even if the “Taxes” kotlin module depends on the “Products” kotlin module.
If they’re completely separate, you can have multiple, but you will get some duplicate binary which will take up disk space (maybe have some memory implications? That’s a wild guess and probably insignificant, but disk space for sure).
Oh, ha! I wrote that answer in SO. I just gave a talk about this, but it’s not public yet. I try to explain the “why” a bit better in the talk. May be time for a new blog post.