https://kotlinlang.org logo
r

Rafs

06/22/2023, 8:28 AM
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

ribesg

06/22/2023, 8:35 AM
You can't, unless that changed and I didn't hear about it.
r

Rafs

06/22/2023, 9:01 AM
Actually i've been able to do it by manually adding an extra value to the
Framework Search Paths
in XCode
r

ribesg

06/22/2023, 9:13 AM
I wonder how that works. Each KMM framework includes its dependencies so you have them multiple times
a

Arkadii Ivanov

06/22/2023, 9:21 AM
I find the following article pretty useful: https://touchlab.co/multiple-kotlin-frameworks-in-application/
r

ribesg

06/22/2023, 9:23 AM
So basically, it has been working since Kotlin 1.3.70, but don't do it 😄
r

Rafs

06/22/2023, 9:26 AM
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

Arkadii Ivanov

06/22/2023, 9:26 AM
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

ribesg

06/22/2023, 9:29 AM
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

Rafs

06/22/2023, 9:31 AM
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

Arkadii Ivanov

06/22/2023, 9:34 AM
I would create an ambrella module, and export it as a Framework, with dependencies added as
api
.
r

Rafs

06/22/2023, 10:00 AM
I've just tried this but the framework isn't getting generated for the umbrella module @Arkadii Ivanov
a

Arkadii Ivanov

06/22/2023, 10:12 AM
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

Rafs

06/22/2023, 10:57 AM
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

Arkadii Ivanov

06/26/2023, 8:54 AM
Well, you could put a dummy class or function there as a workaround.
r

Rafs

06/26/2023, 8:54 AM
Yeah that's what i'm doing now, but thats what I was hoping I wouldn't have to do 😀
x

xiaobailong24

06/27/2023, 6:42 PM
12 Views