Develop both for Android and iOS

To develop an app in Android and iOS native platform we need to have

  • separate developers for both the Android and iOS platform
  • Separate business logic for both the platform
  • Separate testing team for both the platform

Hence we need

Team

Cost

2x Time

Bug fixes

To develop application for Android, iOS and Web we need

Team

Cost

3x Time

Bug fixes

What is the solutions for the above problem:

Cross platform is the solution for the above problem and there are many cross platforms framework available like Xamarin, Ionic, React-native, Kotlin multi-platform and Flutter but here i will discuss about the Kotlin Multi-platform.

What is KMP:

Support for multiplatform programming is one of Kotlin’s key benefits. It reduces time spent writing and maintaining the same code for different platforms while retaining the flexibility and benefits of native programming.

Kotlin Multi Platform provides a way to share common business logic and build apps for different platforms using Kotlin.Kotlin Multi Platform is a kotlin language feature that allows us to run Kotlin in JavaScript, iOS, and native desktop applications and hence develop apps using Kotlin. Kotlin multi platform will take care of the business logic and rest we have to take care of UI only.

With out KMP

Without KMP we have to write separate Network code, model classes, response parsing code and common presentation logic code for all the platforms for Native, JVM and JS hence we will require more resources, time and cost.



With KMP:

With KMP we have to write single Network code, model classes, response parsing code and common presentation logic code for all the platforms for Native, JVM and JS hence we will reduce the number of resources, time and cost.


Why KMP?

Kotlin Multiplatform is an experimental language feature that allows you to run Kotlin in JavaScript, iOS, and native desktop applications. We can share code between all these targets, reducing the amount of time required for development. Below are some of the key features.

  • Business logic reusability
  • Smooth interoperability
  • Native UI
  • High performance
  • Improved flexibility and scalability

KMP Behaviours:

The common code is compiled to Bytecode which can be directly used by android and for native the common code is compiled to iOS executable code

Working process of KMP:

Kotlin konan compiler compile to bytecode which is used by Android or any app which use bytecode, and for JS the compiler compiles to .js hence it can run in browser or Node or React and for ioS Kotlin compiler uses a set of IOS resources and framework that is merged with the common code and generate iOS app

Communication between Common code and target module code:

The common code gets compiled to .kt and the respective target like JVM compile the .kt to .java or jar which can run in android, Native like iOs convert the .kt to .c or swift or any other framework which can run in iOS and the Javascript target compile the .kt to .js which can run in any browser, Node or React.

What can be shared

Here we are sharing the Data layer which holds Repositories, Http clients for network call,  Caches, Domain which holds Entities and interactors, Common Presentations which holds View models,presenters,controllers rest the Android and iOS can have their own presentation for UI


I will come up with a practical guide for the above topics soon...