Same KMP Library for both Android and iOS

Consider if we have a following scenario:

  1. Existing Android (Kotlin) and iOS (Swift) UI Project

  2. Existing Android (Kotlin) and iOS (Swift) SDK Project

  3. Now the UI project is limited to views and view models in Android and to ViewControlllers in iOS

  4. SDK project makes the API call, converting to the local data model classes.

  5. UI project uses those model to show data

Now my requirement is , we don’t want to modify Android and iOS UI projects. Also want to keep their source code separate.

We only plan to merge the SDK projects (Android and iOS) into one or create a new KMP library which will have the SDK features.

Then generate 2 different executables from it for Android ( jar or aar ) and one for iOS ( not sure if it is MachO ).

Use these executables as libraries in the specific Android and iOS project.

Do you think KMP provides support for above mentioned scenarios? Or those libraries created can be used only in KMP projects?

2 Likes