
Nowadays, we can observe a trend in mobile development to release apps faster. There were many attempts to reduce the time of development by sharing common code parts among different platforms such as Android and iOS. Some solutions have already gained popularity, while others are still under development. Today, I’d like to discuss one of the newest approaches from the second group – Kotlin Multiplatform Mobile (KMM for short).
What is Kotlin Multiplatform Mobile?
KMM is an SDK that primarily aims to share business logic among platforms – the part that in most cases has to be the same anyway. This is achieved thanks to a set of multiple compilers for a shared module. For example, Android target uses a Kotlin/JVM variant, and for iOS there is a Kotlin/Native one. A shared module can be then added to typical native app projects and developers responsible for UI can focus on delivering the best experience for users in an environment familiar to them – Android Studio for Android and Xcode for iOS.
Kotlin Multiplatform vs Flutter
Currently, one of the most popular solutions for cross-platform app development is Flutter. It is focused on the “write one app and run it everywhere” rule – which works, but only for simple apps. In real case scenarios, developers often have to write native code for each platform anyway to fill the gaps, for example, when some plugin is missing. With this approach, the app looks the same on different platforms, which sometimes is desirable, but in some cases, it can break specific design guidelines.
While they may sound similar, Kotlin Multiplatform is not a cross-platform solution – it doesn’t try to reinvent the wheel. Developers can still use tools they know and like. It just simplifies the process of reusing parts of code that previously should have been written multiple times, like making network requests, storing data and other business logic.
Pros and cons of Kotlin Multiplatform
Pros of KMM:
- The developed app is 100% native for each platform – it is easy to integrate with currently used code and third party libraries
- Easy to use – almost all Android developers already use Kotlin, so there is very little additional knowledge required for them to get started
- UI can be split for each target platform – the app will feel consistent with any given ecosystem
- Shared logic allows developers to add new features and fix bugs on both operating systems at the same time
Cons of KMM:
- Many components are still in Alpha/Beta stage and potentially can be unstable or change in future
Which companies use KMM?
According to the official site, companies are increasingly gaining interest in this technology and the list is continuously getting longer and longer. Among them, there are such well-known brands like Autodesk, VMWare, Netflix or Yandex.
How to get started with KMM?
The best place to dive for in-depth information is the official guide, but in this article, I would like to show an example that is fairly simple, but more interesting than just a “Hello World”, which would be app fetching and displaying the latest comic by Randall Munroe (licensed under CC BY-NC 2.5) with its title from xkcd.com API.
Features to be covered:
- Project setup
- Networking in the shared module
- Simple UI for both Android and iOS
Note: I wanted this sample to be as easy to read for both Android and iOS developers, so in some places I intentionally omitted some platform-specific good practises just to make it clear what is going on
Summary
Finally, to answer the question from the title – Is Kotlin Multiplatform the future of cross-platform development? – it all depends on the needs. If you want to create a small, identical app for both mobile platforms at the same time, then probably not, because you need to have the required knowledge on development for both platforms.
However, if you already have a team of Android and iOS developers and want to deliver the best user experience, then it can significantly reduce development time. Like in the provided example, thanks to a shared module, application logic was implemented only once and the user interface was created in a fully platform-specific way. So why not give it a try? As you can see, it’s easy to get started.
info@babyboxtech.com
Phone number
US: +1-415-496-9561
CN: +86 156-433-1672