The development of mobile cross-platform apps is now a viable alternative to native development. With cross-platform development, developers can create an app in one go and then simultaneously release it for Android and iOS. It has gained much attention from startups since it is a quick and cost-effective method of reaching an array of users.
One of the most recent cross-platform frameworks that have hit the scene is Kotlin Multiplatform. It is evident from the following table by Statista that Kotlin Multiplatform is not among the top market shareholders. While it’s yet to be introduced on the scene, I think it has promising features that will bring more developers to the platform over the next year.
Introduction to Kotlin:
Kotlin is a framework for development that JetBrains launched in the year 2011. It was named in honor of Kotlin Island, an island situated near St. Petersburg, as an allusion to Java’s Java Island name. Kotlin was released officially in the year 2016. In the year 2017, Google announced first-class support for Kotlin on Android. In 2019, Google announced Kotlin as the preferred language for Android app developers instead of Java.
Kotlin is a statistically typed programming language that fully integrates with Java. It supports procedural as well as object-oriented programming. Kotlin mainly targets Java virtual machine (JVM) but can also convert it into JavaScript (e.g., for front-end web apps using React) and native codes with LLVM (e.g., for native iOS applications).
Although Kotlin is primarily a software programming language, it also has another aspect: Kotlin Multiplatform. Kotlin Multiplatform is developed to permit compilation on platforms that do not have virtual machines feasible or desirable, for example, embedded devices or iOS.
The platforms that are targeted for Kotlin Multiplatform are:
- MacOS
- IOS, TVOS
- watchOS, tvOS
- Linux
- Windows (MinGW)
- Android NDK (code written in C/C++)
Kotlin Multiplatform Mobile (KMM):
KMM is an application development kit (SDK) designed for iOS and Android application development that gives all the benefits of developing native and cross-platform apps that share code with Android and iOS. The beta was released in the year 2020, which means numerous companies are waiting to upgrade until it becomes more well-established and stable. However, some production apps run with KMM, including Philips, Netflix, Leroy Merlin, and VMWare.
Why KMM?:
The advantages of KMM are:
- Constructing apps for Android as well as iOS applications simultaneously
- DRY (Do not repeat yourself) principle. Sharing code across iOS and Android helps you avoid doing the same thing repeatedly.
- The KISS (Keep it Simple, dumb) principle. Working inside KMM’s KMM shared library helps keep your codebase tidy and organized.
- allows software engineers to develop features rapidly but with high quality.
In KMM, you can make use of one shared script to compose:
- Data Models/Serialization using API JSON
- API Authentication and Calls
- Analytics Tags
- Monitoring of any exceptions or issues
- Caching
Accessibility Voiceover versions of text retrieved from API calls
- Dev/Feature Switch Management
- Any business rules which required manipulating data before its transfer to the client
- Data mocks to test for compatibility with iOS and Android
When working with KMM applications, it is usually possible to have one shared module, an iOS application, and one Android application. The shared module includes all the common logic of Android and iOS applications. When you build the scripts, they are made to become an Android library and the iOS framework. KMM has a common source program that performs the business logic, and the shared module defines the method used to invoke any native APIs you want to use within your application. For instance, if you have a Unique Identifier (UID) within the standard code, you may define a method to call an operating system specific to one of the two libraries.
As you see from the image below, KMM can be highly beneficial in business logic and the data layer.
Your application’s data and business logic layer can be fully shared with Android and iOS using KMM. Since KMM was first released, it has seen more efforts to boost presentation and UI logic sharing.
Based on the findings from the Kotlin Multiplatform Survey in Q1-Q2 2021, we can observe that the vast majority of networks and data storage used KMM:
Final Thoughts:
That is a short description of KMM and doesn’t go into the specifics of KMM. As with all frameworks, KMM comes with its benefits and issues. Overall, I think the advantages of KMM include the shared and reused code library and the speed of development, which will allow KMM to gain popularity and traction with software developers. Visit their website for more information.