Kotlin Multiplatform Development stable Help

Set up an environment

Before you create your first application that works on both iOS and Android, you'll need to set up an environment for Kotlin Multiplatform development.

Install the necessary tools

We recommend that you install the latest stable versions for compatibility and better performance.

Tool

Comments

Android Studio

You will use Android Studio to create your multiplatform applications and run them on simulated or hardware devices.

Xcode

Xcode is required if you have a Mac with macOS and want to write iOS-specific code and run an iOS application. If you use a different operating system, skip this tool.

Launch Xcode in a separate window to accept its license terms and allow it to perform some necessary initial tasks.

Most of the time, Xcode will work in the background. You will use it to add Swift or Objective-C code to your iOS application.

JDK

To check whether it's installed, run the following command in the Android Studio terminal or your command line:

java -version

Kotlin Multiplatform Mobile plugin

In Android Studio, select Settings/Preferences | Plugins, search Marketplace for Kotlin Multiplatform Mobile, and then install it.

Kotlin plugin

The Kotlin plugin is bundled with each Android Studio release. However, it still needs to be updated to the latest version to avoid compatibility issues.

To update the plugin, on the Android Studio welcome screen, select Plugins | Installed. Click Update next to Kotlin. You can also check the Kotlin version in Tools | Kotlin | Configure Kotlin Plugin Updates.

The Kotlin plugin should be compatible with the Kotlin Multiplatform Mobile plugin. Refer to the compatibility table.

Browsers

To run multiplatform applications in a browser, you need a browser supporting the Wasm Garbage Collection (GC) feature.

  • Chrome and Chromium-based: works by default starting from version 119.

  • Firefox: works by default starting from version 120.

  • Safari/WebKit: Wasm GC support is currently under active development.

Check your environment

To make sure everything works as expected, install and run the KDoctor tool:

  1. In the Android Studio terminal or your command-line tool, run the following command to install the tool using Homebrew:

    brew install kdoctor

    If you don't have Homebrew yet, install it or see the KDoctor README for other ways to install it.

  2. After the installation is completed, call KDoctor in the console:

    kdoctor
  3. If KDoctor diagnoses any problems while checking your environment, review the output for issues and possible solutions:

    • Fix any failed checks ([x]). You can find problem descriptions and potential solutions after the * symbol.

    • Check the warnings ([!]) and successful messages ([v]). They may contain useful notes and tips, as well.

Possible issues and solutions

Android Studio

Make sure that you have Android Studio installed. You can get it from its official website.

Java and JDK
  • Make sure that you have JDK installed. You can get it from its official website.

  • Android Studio uses a bundled JDK to execute Gradle tasks. To configure the Gradle JDK in Android Studio, select Settings/Preferences | Build, Execution, Deployment | Build Tools | Gradle.

  • You might encounter issues related to JAVA_HOME. This environment variable specifies the location of the Java binary required for Xcode and Gradle. If so, follow KDoctor's tips to fix the issues.

Xcode
  • Make sure that you have Xcode installed. You can get it from its official website.

  • If you haven't launched Xcode yet, open it in a separate window. Accept the license terms and allow it to perform some necessary initial tasks.

  • You may encounter Error: can't grab Xcode schemes or other issues regarding command line tools selection. In this case, do one of the following:

    • In Terminal, run:

      sudo xcode-select --switch /Applications/Xcode.app
    • Alternatively, in Xcode, select Settings | Locations. In the Command Line Tools field, select your Xcode version.

      Xcode schemes

      Make sure that the path to Xcode.app is selected. Confirm the action in a separate window if required.

Kotlin plugins

Kotlin Multiplatform Mobile plugin

  • Make sure that the Kotlin Mobile Multiplatform plugin is installed and enabled. On the Android Studio welcome screen, select Plugins | Installed. Verify that you have the plugin enabled. If it's not in the Installed list, search Marketplace for it and install the plugin.

  • If the plugin is outdated, click Update next to the plugin name. You can do the same in the Settings/Preferences | Tools | Plugins section.

  • Check the compatibility of the Kotlin Multiplatform Mobile plugin with your version of Kotlin in the Release details table.

Kotlin plugin

Make sure that the Kotlin plugin is updated to the latest version. To do that, on the Android Studio welcome screen, select Plugins | Installed. Click Update next to Kotlin.

You can also check the Kotlin version in Tools | Kotlin | Configure Kotlin Plugin Updates.

Command line

Make sure you have all the necessary tools installed:

Browsers

Make sure that your browser version supports the new WasmGC by default. If you are working with older browser versions, configure the environment.

Still having trouble?

Share your problems with the team by creating a YouTrack issue.

For a smoother multiplatform experience, you can also try JetBrains Fleet: it integrates with Compose Multiplatform and allows writing Swift code without switching to Xcode, with less IDE juggling overall.

Next step

In the next part of the tutorial, you'll create and run your first Compose Multiplatform application.

Proceed to the next part

Get help

Last modified: 13 May 2024