How did we decide to use KMM (Kotlin Multiplatform Mobile) at Formaloo?

Tadeh Alexani
Formaloo
Published in
5 min readSep 16, 2020

Introduction of Formaloo

First, let me introduce you to Formaloo:

Formaloo Customer Data Platform (CDP) collects, analyzes, and unifies data from all data sources to grow customers’ loyalty. It’s a business productivity solution built to transform the way people collect information and put it to work.

Formaloo CDP

Formaloo is specially designed not only for routine data collection like surveys and simple forms but for Businesses and Professionals who deal with valuable and complex data.

At first, we developed and launched our product’s web version, which was a huge success. Then, we decided to develop an Android version of our product which is now available in Google Play and has more than 15,000 installs.

Formaloo has now more than 100,000 Data sources integrated and analyzed over 1 million unique customers’ data.

Now, it’s time for iOS!

After testing and getting feedback from our Android app from our users, we decided it’s now time to develop an iOS app too. There were some solutions ahead of us:

  • To write it natively: This my personal
  • To switch to a hybrid approach (like React Native, etc.)
  • To use cross-platform tools like KMM, etc.

I would always prefer native approaches myself and I hate hybrid approaches using React Native or Xamarin. But there is a big BUT here. The logic shared around our apps is the same. So using the native approach I, as an iOS developer, must write the model, view model, and networking code again in the iOS native language, When there’s a complete logic part of the app written and tested via our Android developer. Also, whenever a feature needs to be added or a change must be applied, both of us should apply it to our different logic layers which can be a job done twice.

So we decided to do more research about the third approach above us: To use cross-platform tools. After doing some research we came across KMM (Kotlin Multiplatform Mobile). This was a good option for us because our Android app, as mentioned above, is already written in Kotlin and is also tested several times by the users and our QA team.

What is KMM?

KMM

According to KMM’s official website:

Kotlin Multiplatform Mobile allows you to use a single codebase for the business logic of iOS and Android apps. You only need to write platform-specific code where it’s necessary, for example to implement a native UI or when working with platform-specific APIs.

So, if it’s how it works, let’s try it!

This was a great option for us because we have already written the logic part of our app and also the UI of our Android app is also fully written. Surely there will be needed some changes in the Android code (which we’ll discuss soon) but we estimated the time difference which it can make in developing the iOS app and it worth a try.

First Step: Knowledge Sharing

After our initial decision, we had some knowledge sharing experience which I would like to share the gist of it with you:

  • In the Android Side, the logic part must be updated.
  • In the Android Side, the libraries must be updated:
    KMM only supports multiplatform libraries, so it’s a bit limited, for now.
    This is what Kotlin documentation is saying:
    Kotlin Multiplatform Mobile is still young, but the ecosystem has tremendous potential as there are already a lot of modern libraries written in Kotlin that can be easily ported to multiplatform.
  • There are some platform-specific functions in the KMM’s logic layer which you can implement it using the expect keyword (it works like an interface). Then you can implement the body of those functions with the expect keyword in iOS or Android separately. For example please take a look at the link below:
    https://kotlinlang.org/docs/mobile/connect-to-platform-specific-apis.html#example-generate-a-uuid
From play.kotlinlang.org

Second Step: Build Something!

Both sides (Android & iOS) cloned the repository below and tested if they can build the project in the first place and everything is ok:
https://github.com/kotlin-hands-on/kmm-networking-and-data-storage/tree/final
We selected this project because it has both networking and database implementation with the multiplatform libraries.

We followed the tutorial below which has a good explanation:

Issue? No Issue :)

What issue did we face? On the iOS side, the first building process took so long that I thought there’s some problem on my side. I thought I should install Android Studio and build the project. But after some time we found out that it was because some huge files are being downloaded from the internet so it caused some delay on the first run😄

Our Next Step

We have planned to write a small sample application with the base of our product (Formaloo) to test different parts of the KMM in action and make the final decision about using or not using KMM for the bigger project. We will share the result with you in the second part of this series of articles. Enjoy!🎉

Your Next Step

If you’re a developer or a product manager and after reading this article found it interesting and want to introduce this method to your team, I highly recommend you to read this article first and take its advice:

Happy Convincing Your Team! :)

UPDATE Sept 19, 2020: After implementing the test project, we had the conclusion that updating our logic part with the current multiplatform libraries would take longer then we expected, and also for even the simplest issues there were not many answers in the community. So at this stage, we decided to keep our Android app on Kotlin and write a native iOS app with Swift & SwiftUI.

--

--