skip to Main Content

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?

2

Answers


  1. 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

    Login or Signup to reply.
  2. You can achieve this using Android Build variant (productFlavor), You would have 1 Main source code with the shared logic, and then you create new package one for your Customer and one for your Business and inside you put the difference code only.

    to read more check this out build-variants

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search