Tools
November 26, 2022

Multiplatform Development, as It Always Should Have Been

Multiplatform Development, as It Always Should Have Been

Multiplatform development at its most basic level means developing for both Android and iOS in the same codebase - implemented properly it should reduce your workload and require fewer resources since there's only one codebase to maintain.

Implementing it properly is the key, though. Multiple solutions have been created for multiplatform or cross-platform development (the most popular being React Native and Flutter) but they have shortcomings such as large app size, slow performance, and non-native look and feel.

The best solution to this problem is Kotlin Multiplatform Mobile (KMM). Here, you’ll learn more about this cross-platform framework for mobile and why it’s an improvement over previous attempts at cross-platform development.

What Is Kotlin Multiplatform Mobile?

Kotlin Multiplatform Mobile is an SDK for iOS and Android app development. You can use it to develop multiplatform applications, sharing logic between Android and iOS, while also developing native UIs for the two platforms. This allows you to reap the combined benefits of creating cross-platform and native apps. Your apps get to share code across platforms while maintaining the performance and look of a native app.

Unlike other multiplatform frameworks, KMM allows for both shared code and native code. You can maintain a single codebase for business logic, storage, network, and logging. This codebase will be implemented in Kotlin and shared between the Android and iOS platforms. It is worth noting that while Android can natively run Kotlin, for iOS, KMM cross-compiles Kotlin code in Objective-C that runs on iOS. You can also write native code for user interfaces (UIs) using SwiftUI and Jetpack Compose to access device-specific features.

KMM structure


Image courtesy of JetBrains

KMM’s codebase is in Kotlin, a modern JVM language that 60 percent of Android applications already use. Kotlin is a powerful, expressive, and concise programming language that can be used for both frontend and backend projects. It comes with a host of features like type and null safety, built-in concurrency, extension functions, and higher-order functions for faster, more efficient app development.

Benefits of Multiplatform Development

Using KMM for multiplatform development offers the following benefits.

Less Development Required

Because you only need to write your logic once, you aren’t adding to your workflow by duplicating your efforts across platforms. You also don’t need as many developers, since you write once and deploy everywhere. Since Kotlin is already popular with mobile and backend developers, your team will spend less time learning new technologies and more time building out new features.

Faster Time to Market

Since you don’t need to produce as much code, you’ll get more done in less time. With faster development cycles, your team will be quicker to market and you can stay ahead of your competitors. Kotlin as a modern language also provides handy features such as data classes, extension functions, and functional programming that make it easier and faster to write apps.

Reusable Code

KMM enables you to reuse your code across devices, because it allows for the development of native, web, and desktop applications. By using KMM for native app development, you can also use the shared code in your web and desktop apps.

Easier Product Maintenance

KMM also provides for easier maintenance. Since KMM apps share code, if a bug is found, it is fixed once for both platforms. Tests are also more robust since most of the code is implemented centrally. Kotlin comes with a powerful testing library and built-in support for development and debugging in Android Studio. The time saved on writing code frees you up to write tests and increase test coverage.

Best for Platform Design

The best part about KMM is that the UI is completely native. You can develop your UI using the library for your chosen framework, such as SwiftUI for iOS or Jetpack Compose for Android. This ensures your UI is rendered quickly and has the native look and feel of its platform.

KMM and Other Frameworks

Kotlin Multiplatform has a lot to offer your organization, but what about other multiplatform development frameworks? The following are details on some of the most used frameworks and how Kotlin compares to them.

Flutter

Developed and released by Google in 2017, Flutter is the most popular cross-platform development framework. Flutter has a strong community and comes with a rich catalog of components and widgets. It also comes with hot-reload functionality, allowing developers to preview their changes live and in real time without rebuilding the whole project.

However, there are several caveats to Flutter. In order to code Flutter-based mobile apps, developers need to learn the Dart language. Flutter is still relatively young, with limited tooling and plug-ins. Its apps, though fast, are also relatively large compared to native apps. This is because Flutter apps ship with the Flutter core engine, which is responsible for the low-level implementation of Flutter’s core API, including graphics, text layout, file, and network I/O, and a Dart runtime and compiler toolchain. To add to all that, Flutter developers risk that the framework might be discontinued as many other Google projects have in the past.

React Native

React Native is the second most popular multiplatform development kit. Based on the React library, React Native uses JavaScript to write code for both mobile platforms. React Native comes with UI components that map to native components to give your app the look and feel of a native app. It is also used in apps for Facebook, Instagram, and Skype.

React Native is ideal for React web developers who want to start developing mobile apps using their existing skill set. React Native apps, however, offer limited out-of-the-box UI components. This means that the apps don’t have a native look and feel, especially when it comes to custom components. React Native apps are also slower than native apps. Because JavaScript is single threaded, all your React code is executed via this single thread over the React native bridge to the core platform. React apps are also large. A simple hello world application with React Native can be as large as 13 MB.

Xamarin

Xamarin is an open source cross-platform framework from Microsoft. Launched in 2011, it offers a way to develop multiplatform apps using C# and .NET. Xamarin apps are developed in Visual Studio, a mature and feature-rich IDE for the .NET ecosystem. Like KMM, Xamarin allows developers to write a shared logic for both platforms while also providing the option to add a native layer for platform-specific code. Xamarin UI components are converted into platform-specific interface elements at runtime, giving it near-native performance when rendering.

However, a major drawback of Xamarin is that it doesn’t support development using Linux, the second most used OS for developers. Another drawback is that Xamarin apps are developed in C#, a language with little popularity among mobile and frontend developers. Due to this, Xamarin only commands 11 percent of the mobile development market and has a smaller community. Additionally, UIs in Xamarin are implemented using XAML, which renders them as a tree. This is a bit slower to render and less intuitive than the new composable structures used by Flutter, Jetpack Compose, and SwiftUI. Xamarin also has limited plug-ins and libraries, especially for new features.

Apache Cordova

Apache Cordova is a cross-platform framework for developing mobile apps using HTML, CSS, and JavaScript. Initially released in 2009, Cordova is one of the oldest cross-platform development frameworks. It allows developers to create mobile apps using web technologies, and it provides plug-ins for accessing native features such as the camera, network, media, and contacts. Other frameworks like Ionic, App Builder, and Framework7 use Cordova as a base.

Cordova presents some challenges, though. As with other hybrid technologies, Cordova apps are slower than native apps. Since Cordova apps are rendered inside a WebView and don’t have native components, cross-browser compatibility issues can cause app instability. This also means Cordova apps will look more like web apps than native mobile apps. Cordova does not yet support some native APIs, so developers may have to write their own plug-ins for them.

Why Kotlin Is Better

Kotlin Multiplatform Mobile solves many of the pain points noted in the above cross-platform frameworks. KMM apps use the platform’s underlying native languages. Because of this, they are highly performant compared to other cross-platform solutions. Their UIs are natively developed, making them fast to render and allowing them to maintain the look and feel of a native app. KMM allows mobile developers to build with tools and languages they already know, such as Android Studio, Xcode, Kotlin, SwiftUI, and Jetpack Compose. This reduces the learning curve and simplifies the development process. Existing apps can also be easily converted into KMM apps.

Finally, since KMM doesn’t impose restrictions on what developers add to their shared and native code, they can migrate their apps iteratively, sharing only the code they are comfortable with at the time.

KMM is modern, robust, and the best solution for multiplatform development. It integrates with existing tools and doesn’t try to reinvent the application development process. With KMM, native app developers don’t have to throw away their skills to learn a new stack, but can continue applying their knowledge and expertise around Android or iOS. Developers get to share code and logic while using familiar tools and frameworks, reducing development time, effort and resources.

Other Tools for Success

Using Kotlin Multiplatform Mobile can boost your organization’s mobile development strategy because of the versatility and high performance that it offers. But there are other tools that can help you achieve similar results.

For example, Unflow offers an easy-to-use visual editor to help with your cross-platform development. The Unflow Mirror app lets you preview your projects in real time before releasing them. It offers native SDKs on Android, iOS, React Native, and Flutter, and it provides a customizable UI as well as testing and analytics. Check the documentation for more information.

Conclusion

Kotlin Multiplatform Mobile provides a new and improved way to perform multiplatform development. It gives you all the benefits of cross-platform development with none of the disadvantages, because the apps produced are truly native apps. Your team can even decide how much of the logic to share between Android and iOS apps, which helps remove complexity and allows for gradual migration of existing apps.

Other multiplatform frameworks and tools offer their own benefits, but KMM’s ability to support both shared code and native code gives it an edge over its competitors. Using it for your cross-platform development will help you save on costs and resources while you create higher-quality products.

Michael Nyamande

What are you waiting for?

Make apps smarter,
with Unflow

Thanks for your interest!
Something's gone wrong while submitting the form