How do I reference more than one KMM frameworks in...
# compose-ios
r
How do I reference more than one KMM frameworks in the iOS app. I've tried playing with the linker settings in XCode but it doesn't seem to be helping. It works if I link the original shared module that was created by Android studio, but anything else doesn't work.
👍 2
r
You can't, unless that changed and I didn't hear about it.
r
Actually i've been able to do it by manually adding an extra value to the
Framework Search Paths
in XCode
r
I wonder how that works. Each KMM framework includes its dependencies so you have them multiple times
a
I find the following article pretty useful: https://touchlab.co/multiple-kotlin-frameworks-in-application/
r
So basically, it has been working since Kotlin 1.3.70, but don't do it 😄
r
Reason why I started looking into multiple frameworks is because I want to have a different framework for
data
and a different one for
ui
both of which are multiplatform components
a
Well, I can imagine an isolated framework built with Kotlin, that you can include in addition. Yes, it will include all the dependencies. But this might be ok, it depends.
I believe Kotlin frameworks can't really communicate with each other, as explained in the article.
r
Yeah if they are 100% independent, why not. But if at some point you need to pass some class from
data
to a function or something from
ui
, you won't be able to
r
What is the proper way to go if I want them to communicate with each other
Should I have a parent module which will be the framework, and create sub-modules inside of it
a
I would create an ambrella module, and export it as a Framework, with dependencies added as
api
.
r
I've just tried this but the framework isn't getting generated for the umbrella module @Arkadii Ivanov
a
Here is an example of an umbrella module: https://github.com/JetBrains/compose-multiplatform/blob/master/examples/todoapp/common/root/build.gradle.kts Basically, you export it the same way. Just one module instead of two.
r
Thanks @Arkadii Ivanov, I managed to get it to work by following the sample.
@Arkadii Ivanov One thing i've noticed from using the umbrella module is that the framework doesn't get generated if there aren't any sources for the umbrella module itself. For instance, if I delete
src/commonMain/kotlin
then the framework isn't generated and XCode will report a no mudule found error. I don't want to have any sources in there
a
Well, you could put a dummy class or function there as a workaround.
r
Yeah that's what i'm doing now, but thats what I was hoping I wouldn't have to do 😀
x
389 Views