Anyone have any experience utilizing a `klib`? Or ...
# kotlin-native
j
Anyone have any experience utilizing a
klib
? Or know of a good tutorial or more detailed documentation on the native libraries than I see on Jetbrains’ website? I’ve made a iOS framework with Kotlin Native, but there is a restriction they’ve created where you can only have one kotlin iOS framework in an app at a time. In an effort to modularize my shared code, I’d like to find a way to use several kotlin libraries in an iOS app at once. I believe for now I’ll need to create one Kotlin Native project that pulls in a bunch of libraries and spits out one bundled framework. But working with Gradle (not my forte) and this experimental stuff has got my head in a fog. Ex:
Copy code
Modules
----------
Models feature A
Models feature B
Models feature C
API-Client feature A
API-Client feature B 
Other Business Logic
If our organization wants to use Feature B in another application I’d hate to have to pull all of that shared logic to the other app when I only want what matters to Feature B
s
That's basically the way it works. You can publish all of your individual features to separate maven projects and then pull them in as dependencies in your app frameworks. Unless you're sure that you will actually be doing a second project with a subset of your features, you can start small by putting your individual features in separate gradle modules and then pulling them into your app framework by using
implementation project('module-A')
in it's dependencies section.
j
I think that is the line of code I’ve been missing. I tried to have a Kotlin Native Library project with separate modules but failed to link them properly.
s
Gradle is a pain even for people that are familiar with it. I definitely am not. There are some good MPP examples out there that have helped me. I recommend going with the MPP plugin even if you're only going to have an iOS framework since that is the best supported in IntelliJ.
j
know any good gradle tutorials that covers either publishing your own dependencies and consuming them or the nested project structure and referencing the other modules from a parent or sibling module?