Kotlin Multiplatform Mobile Goes Alpha
Kotlin Multiplatform Mobile (KMM) is an SDK that allows you to use the same business logic code in both iOS and Android applications. Today KMM goes Alpha, and you can start sharing business logic in your mobile apps with it right away. It includes the new KMM Plugin for Android Studio, which allows you to write, run, test, and debug shared code in the same IDE. Join such great teams as VMWare, Autodesk, and Yandex who are sharing code in their mobile apps using Kotlin. Reusing code between mobile platforms has never been so easy!
What is Kotlin Multiplatform Mobile?
Kotlin Multiplatform Mobile (KMM) is an SDK for cross-platform mobile development provided by JetBrains. It uses the multiplatform capabilities of Kotlin and includes various tools and features designed to make the end-to-end experience of building mobile cross-platform applications as enjoyable and efficient as possible.
The Android and iOS versions of an application often have a lot in common, but they can also differ significantly – especially in terms of their UI – from subtle variations in scrolling behavior to completely divergent navigation logic. At the same time, the application’s business logic, including such features as data management, analytics, and authentication, is often identical. That’s why it’s natural to share some parts of an application across platforms while keeping other parts completely separate.
With KMM, you can get this flexibility and retain the benefits of native programming. Use a single codebase for the business logic of iOS and Android apps and write platform-specific code only where it’s necessary, to implement a native UI or when working with platform-specific APIs.
KMM is seamlessly integrated with your mobile project. Shared code, written in Kotlin, is compiled to JVM bytecode with Kotlin/JVM and to native binaries with Kotlin/Native, so you can use your KMM business-logic modules just like any other regular mobile library.
Sharing Kotlin code between mobile platforms has already saved a lot of time and effort for many companies. Here are some inspiring stories:
- Fastwork introduced KMM for the domain and data layers of their application to share business logic and API service between mobile platforms, significantly boosting their team’s productivity.
- Yandex.Disk started out by experimenting with the integration of a small feature, and when the experiment proved successful, they implemented their whole data synchronization logic in KMM.
The remarkable results achieved by these and many other teams have been a big part of our inspiration, and we hope that their stories will encourage you to start sharing code between mobile platforms with KMM.
Enjoy creating mobile apps with KMM
KMM is still quite new to the mobile development world, but we believe that it is a true game-changer. That’s why we allocated a separate team inside Kotlin to push KMM forward and provide the best developer experience for the creation of cross-platform mobile applications with Kotlin.
As a first step toward this, today we are happy to present to you the first preview of the KMM plugin for Android Studio along with the new KMM developer portal.
Let’s start our KMM Journey!
Work in a familiar environment
With the new KMM plugin, you can write, run, test, and debug shared code in Android Studio, without switching to other IDEs. To install it, select Preferences | Plugins, search for the Kotlin Multiplatform Mobile plugin in Marketplace, and click the Install button.
Configure a new application in a few clicks
With the New Kotlin Multiplatform Mobile Project wizard, you can create a ready-to-run mobile application project with a shared codebase in just a few clicks. To see how it works on both platforms, just select the run configuration you need and click the Run button.
The generated project will contain examples of how to connect to platform-specific API and basic test coverage. You can use this wizard to explore the basic features of KMM or as a scaffolding tool for your new KMM production application.
Follow this tutorial to install the plugin and create your first multiplatform application with the wizard.
Introduce KMM to your existing project in one step
You also can start your KMM journey right in your current project: the shared Kotlin code can be easily integrated into your existing code just like any other regular dependency. The New Kotlin Multiplatform Mobile Module wizard will help you add a new KMM module to your project, so you can use the code you’ve already written in Kotlin and refactor it to make it compatible with iOS.
Check out this guide to integrating KMM into existing projects to learn how to design the architecture of multiplatform projects and organize the migration to it.
Work with both platforms within one IDE
You no longer need to switch IDEs and have Xcode running to check that your code works correctly on both mobile platforms. With the new plugin, you get integration with your iOS device and simulator directly in Android Studio. This gives you the following capabilities:
- Run and debug the iOS application on the simulator or a device with the predefined run configuration.
- Run and debug common and iOS specific tests on the iOS simulator by simply clicking the gutter icon on a test class or method.
For both the application and tests you can set breakpoints and debug your code on iOS.
Integrate with the iOS ecosystem without any overhead
As mentioned above, KMM is seamlessly integrated with your mobile project. For Android, you can use Kotlin for every part of your project. At the same time, KMM provides tight integration with the iOS development process, because of Kotlin/Native’s interoperability with Objective-C/Swift, the integration with the CocoaPods dependency manager, and the ability to use platform-specific APIs with the expect/actual pattern.
Enjoy working with Kotlin from Swift code with Kotlin/Native
Kotlin/Native provides bidirectional interoperability with Objective-C/Swift. Kotlin modules can be fully used in Swift/Objective-C. You can use Objective-C frameworks and libraries in Kotlin code, as well as Swift libraries if their API is exported to Objective-C with
Learn more about Kotlin/Native’s interoperability with Swift/Objective-C.
Easily manage iOS dependencies
Kotlin/Native provides integration with the CocoaPods dependency manager. You can add dependencies on Pod libraries stored in the CocoaPods repository or locally, and you can also use multiplatform projects with native targets as a CocoaPods dependency (Kotlin Pod). Manage Pod dependencies directly in Android Studio and enjoy full coding support, including highlighting and completion.
This is how the typical KMM library configuration looks:
Connect the library to your iOS project as a Kotlin Pod by adding its name and path to the
Learn more about CocoaPods integration.
Learn how to create better multiplatform mobile apps on the new Developer Portal
The new KMM Developer Portal is designed to make your journey more comfortable and productive, from your very first experience with KMM all the way through to using it in production.
The documentation section is your trusted resource when you are working with KMM. You will find content for all levels of expertise, from tutorials to get you started to more advanced development topics. It contains useful information about common tasks, like organizing networking and data storage layers and even organizing the development process around KMM.
Looking for new ideas about the benefits of using KMM in your application? Learn from the first-hand experience of a variety of teams who are already using KMM in their products in the case studies section.
The power of the community
We are indebted to the following companies and independent developers whose investment of time, knowledge, and expertise was crucial for this release: Kevin Galligan, Alec Strong, Arkadii Ivanov, Ben Asher, John O’Reilly, Louis CAD, Kris Wong, Aleksey Mikhailov and many other incredible engineers. Thank you for reporting issues on YouTrack, participating in product research and interviews, sharing stories about your experience using KMM, and creating incredible multiplatform libraries!
We also want to thank the teams who helped us create content for the new Developer Portal: Touchlab, IceRock, and Kodein Koders. Your work will help thousands of developers delve deeper into Kotlin Multiplatform Mobile and harness its full power.
You rock, folks!
Try it now
With all these cool features, we are happy to announce that KMM is now in Alpha. This means that the Kotlin team is fully committed to improving this technology and helping it evolve. It is also a signal that the product will develop quickly. We’ll listen to your feedback and provide fixes and improvements as soon as possible. Please help us increase the stability of KMM by reporting any issues you find via our tracker.
Going Alpha means that everything is ready for you to start using KMM to share business logic code between mobile platforms. You can create a new project or easily integrate a KMM module into existing ones. In both scenarios, the work can be done with minimal cost and you can always go back to fully native development. The community is growing fast, and you can influence the development of the whole ecosystem by participating in it.
So now is a great time to start using KMM!
To get the best experience of taking a deep dive into KMM and to discuss all the features you plan to explore, join the community of multiplatform enthusiasts in Slack (get invite here) and subscribe to the "kotlin-multiplatform" tag on Stack Overflow.
Though we try our best, we can’t guarantee a smooth migration just yet. However, we’ll try to avoid compatibility issues as much as possible by using feature flags and providing migration guides for new versions.
Share your feedback
This release is just the beginning of the journey, but we need your help along the way. We look forward to all your feedback, both bad and good. Become an inspiration for others by sharing your stories of using Kotlin Multiplatform Mobile, and please share any ideas you have about how we can improve KMM.
Subscribe to Blog updates
Thanks, we've got you!