Anyone play around with modularizing their multipl...
# multiplatform
d
Anyone play around with modularizing their multiplatform project? I only have 2 targets (Android/iOS) at the moment, but I think it’d be nice to create a multi module setup for the app such that I have different modules for features, database, etc. Has anyone done this before?
r
should be similar to a normal android app modularization
👍 2
a normal library module that have android and IOS targets
a
One tip from iOS side: use only one umbrella module to include it into your iOS project, otherwise you will have multiple implementations of internal KMM classes in your project, which may cause unpredictable bugs or compilation problems.
👍 3
a
Andrei, can I ask you to add all these best practices on official KMM guides? It is hard to search all these replies in these threads to understand how to build production-ready multiplatform app. Thanks.
👍 1
k
It's pretty common. Recent example: https://github.com/touchlab/GitPortalTemplateLibrary. See https://github.com/touchlab/GitPortalTemplateLibrary/blob/main/allshared/build.gradle.kts. Include modules as project dependencies. This isn't a "great" example because this particular template is intended to be published to the Android/iOS apps externally, but it shows the basic model. Another here (basically the same code, but for different purposes): https://github.com/touchlab/KMMBridgeSPMQuickStart. In the "testapps" folder you can see how to wire it all up. For iOS, you essentially have to use an umbrella. While creating individual frameworks would result in multiple implementations of KMM classes, which is extra binary bloat for little purpose, you also can pass objects between them, even if they're the "same" object. They're different at a binary level.