Kotlin Multiplatform Mobile: How to create a project

Kotlin Multiplatform Mobile (KMM) has been announced some time ago, currently many things are in alpha but a lot of big teams started using it in their projects. You can track “alpha/beta/stable” here.

First thing, if you don’t know what is Kotlin Multiplatform Mobile you can read here more about it, but in short it is an SDK with a Plugin that help us to create a project that supports Kotlin Multiplatform but focusing in mobile features (Android and iOS).

KMM focuses in 3 main modules: 1 for Android, 1 for iOS and the last one (shared) for all the things that are going to be used by Android and iOS modules. This helps a lot because you will have a single codebase and that means maintainable code, easy to test and avoid a lot of boilerplate.

Step #1: Open Android Studio, Go to Plugins, Search for “KMM” and install it.

Step #2: Install SQLDelight (Optional)

For data persistence square team has created a pretty solid library SQLDelight. To get all the power and make our life easier they have also built a plugin that is pretty useful during the development process.

Step #3: Create a New Project

In the “Projects” section select “New Project” and then scroll down to the bottom of the list, and select “KMM Application”.

Step #4: Fill up the required fields

Step #5: Android and iOS

Now you can select what name do you want for Android, iOS and Shared. Shared is the core module that will contains all the business logic, this module is written in pure Kotlin, it is where things like Ktor, SQLDelight, domain layer will be included and specified.

Keep in mind that these names are going to be used as module name, for example here is used “KMM_Android”, “KMM_iOS” and let shared as “shared”:

and that’s it! … you are ready to go, just press run.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pablo Reyes

Pablo Reyes

Senior Android & Flutter Developer