Hello everyone! Have you guys already made a KMM p...
# multiplatform
a
Hello everyone! Have you guys already made a KMM project to build 2 apps? (Not in the sens, 1 app for Android and 1 for iOS, but 2 apps for Android and 2 apps for iOS). For my current project I need to develop 2 apps that are closely related, a lot of UI elements and business-logic are common. To gain some time I was thinking of developing these two apps within one KMM project, but I'm not sure how to approach this... I suppose I should setup a commain module for the shared code, an app1module and an app2module? Or maybe the best and easiest way is to use git submodules? (I'd like to avoid this if possible, but if it is really the only "proper" way, then I'Il just do it)
g
Your main approach seems to be the correct one (1 common module, 2 app modules, all of them KMP). It makes sense as long as you need to have specificities for each app that do not need to be shared. I don’t think git submodules would be of any help
y
Android product flavour and iOS targets might simplify this where it's 1 app module and 1 shared module then you can customise the output so effectively having N amount of apps
👍 1
That's how I set it up for evntt.io ..each app is a flavour and some of them have UI only related to one app and not bundled in others.
a
Thank you for your responses! I guess flavours are also a valid option in my use-case. But the apps even though they share a lot remains quite different, therefore I think that several modules are more appropriate. Do you have any documentation about how to implement this with KMM? I couldn't find any so fare (maybe due to my lack of experience with KMM, sorry in advance if it is already well documented)
g
You would set up your Gradle modules with the kmp plugin just like any module :) At some point in your app modules you will have to include your common code:
Copy code
commonMain.dependencies {
    implementation(project(":common"))
    ...
}
Also, check JetBrains KMP documentation and tutorials, like https://www.jetbrains.com/help/kotlin-multiplatform-dev/get-started.html, this is a good resource to start with if you have no prior experience in kmp. Plus there's plenty of articles and blog posts you can read online!
a
Thanks a lot!! I've used KMP a lot lately, but always got scared to start messing around with Gradle and modules - I'll definitely work on it :)
👍 1
g
Welcome! You can also check my library if you want, it has a published kmp library module + an app kmp module using the lib, however it's using advanced concepts like custom gradle plugins for convention purposes but if you check the code you may understand the gradle "config/build structure" (I also wouldn't recommend to do convention plugins at first if you lack experience with gradle, it can get quite complicated). Good luck with your project!
👍 1