I am making an app that connects customers and businesses. Now I'd like to pack it into a single project as they are thematically connected and might share some of the logic. This would be simple enough with a native app but for multiplatform I am unsure as how to have them organized. Eg I'd have two IOS and two Android modules, but for the shared code, I'd need 3 shared libraries, sharedBussiness, sharedCustomer and common. Would this seperation be too difficult to handle when it comes to generating frameworks and dependencies? As the sharedBusiness/ Customer would depend on the common module, and on the ios side there are frameworks that have to be generated and handled. Is this a common approach/ would it work?
This should work without any problems. If you split your code in many modules, you can include only needed ones for each platform or app.
It's not that easy to add many KMM modules to an iOS app, but you don't need to.
So your may have sharedBusiness
and sharedCustomer
KMM modules, each included by a corresponding application, and both may be just a combination of other KMM modules, depend on common
in your case.
By default it'll only export classes used by headers of the shared
module.
Like, if you have data class SharedBusiness(let common: SomeCommonClass)
, the SomeCommonClass
will be exported, otherwise - it'll not.
So if you need to export all classes and functions from common
module to iOS framework, you can do it using this docs