Skip to content
← All posts

KMP 101 · Part 5

KMP 101: Creating and running your first multiplatform project in Fleet

By 3 min read Updated

Over the last few articles we covered key KMP concepts, from the multiplatform paradigm to setting up the environment.

This time, we’re really getting our hands dirty and building our first “Hello World” on Android, iOS, and Desktop!


First step: ways to create projects

There are several ways to create a new KMP project, for example:

  1. KMP Wizard: This web tool launched in November 2023. Very promising, since JetBrains plans to complement it with templates and other targets.
  2. IntelliJ templates: Both Android Studio (with the KMP plugin) and IntelliJ offer sample projects through “File > New > Project”.
  3. Manual: an option for those who already have a solid grasp and a deeper understanding of KMP, and who adopt specific strategies, like using build-logic (see my article on this topic, Android Platform - Part 3: Sharing Gradle scripts)

Creating a project with the KMP Wizard

Since we’ll be using Fleet for this and the next articles, the KMP Wizard is a perfect option, because Fleet doesn’t have a template mechanism yet.

The Wizard is super intuitive to use, but in case you need a step by step:

  1. Set a name and a project ID
  2. Select Android, iOS, and Desktop
  3. Click Download;

What about the Web? The reason deserves a separate article on Kotlin/JS and Kotlin/Wasm.

In short, the “dream” version of KMP for the web is still experimental, and the JetBrains team chose not to include that target for now.

Importing the new project into Fleet

Using the project generated by the KMP Wizard in Fleet is pretty simple:

  1. Extract the .zip into some folder in your environment
  2. Open Fleet and select Open File or Folder...
  3. Select the entire folder named after your project
  4. A “Trust and Open Folder in Smart Mode” screen will appear. Click trust
  5. Wait a few moments while Fleet starts up your project. You can watch the progress in the top right corner

What is Smart Mode in Fleet?

This feature lets us use Fleet both as a lightweight text editor and as a full IDE. It’s specifically designed to save system resources by enabling heavy IDE features only when needed.

Represented by a lightning bolt icon ⚡️ in the top right of Fleet, Smart Mode is essential for several features, including:

  • Semantic highlighting
  • Auto-complete
  • Refactoring
  • Navigation and search
  • Find usages

Testing on the platforms

If everything went well, Fleet performed the following steps:

  1. Initialized the project
  2. Identified that we have 3 targets:
    1. Android with the green robot icon
    2. iOS with the bitten-fruit icon
    3. Desktop with the elephant icon (from Gradle)
  3. Configured each target and made it available in the “Run & Debug” window (by clicking the ▶️ run & debug icon)

Running the project in Fleet

Now it’s time to try it out! Click on each platform and run our Hello World:

Demo on every platform

Conclusion

Simple, right? It actually took years of development for Kotlin Multiplatform to reach this stage. Today, the community is excited about how easy it is to create native multiplatform projects for Android, iOS, and Desktop in just a few minutes.

Now that we have a base project set up and running, we’re ready to move on to more specific KMP topics.

In the next article, we’ll explore a crucial aspect of Kotlin Multiplatform: integrating with Gradle through the KMP Plugin.

See you then!


🤖 This article was written with the help of ChatGPT 4, using the Web plugin.

The sources and content are reviewed to ensure the relevance of the information provided, as well as the sources used in each prompt.

That said, if you find any incorrect information or believe some credit is missing, please get in touch!


References