IntelliJ IDEA 2017.3: Support for Kotlin Multi-platform Projects

The Kotlin plugin bundled with IntelliJ IDEA 2017.3 has been updated to Kotlin 1.2. The key new feature of Kotlin 1.2 is its support for multi-platform projects – projects where the same code is compiled to target the JVM or JavaScript. Such projects consist of common modules, containing platform-independent code, and platform-specific modules. To support calling the platform-specific APIs from common code, the common code can specify expected declarations, and then platform-specific modules need to provide the actual declarations. The IDE now supports creating and running multi-platform projects, as well as code editing and navigation assistance for expected and actual declarations.

Template Multi-platform project

First of all, now it is possible to create a template project to start exploring the new Multi-platform projects feature.


The IDE will generate a multi-platform project with the following modules: a common module for the shared code between the platforms, and two platform-specific modules, one for JVM and another for JavaScript.


Please keep in mind that multi-platform projects should be built with Gradle.

When you compile a project such as this for a specific platform, IntelliJ IDEA generates the code for both the common and platform-specific parts.

Detecting expected declarations without the corresponding actual declarations

To call platform-specific code from a common module, you can specify expected declarations – declarations for which all platform-specific modules need to provide actual declarations.

Expected declarations should have actual declarations in the platform-specific module.
IntelliJ IDEA 2017.3 will detect and alert you if you try to use an expected declaration without the corresponding actual declarations.


Intention action to create the actual class

For missing declarations for JS and JVM platforms, the Kotlin plugin provides an intention action to create actual declarations.


Navigation between expected and actual declarations.

The IDE provides a gutter icon which lets you easily navigate between expected and actual declarations.


You’re welcome to share your feedback here in the comments or on Twitter. If you encounter any bugs, please don’t forget to report them directly to the issue tracker. Thanks!

Happy developing!

image description