silkger.blogg.se

Kotlin desktop app
Kotlin desktop app












kotlin desktop app

Of course, we can remove targets manually or add additional targets using target presets for the supported platforms. Once we create the Kotlin multiplatform library project using the wizard above, it gives us the default configuration settings and structure of the codebase:Īs we can see above, the wizard generates configuration and structure for the common code and targets for JVM, JS, and Native by default. Please note that we can just as easily create skeletons for other types of multiplatform projects like application, mobile library, mobile application, native application, or even a full-stack application. Let’s have a look at the project template selection wizard in IntelliJ IDEA Community Edition: We’ll use one of the IDEA project templates to generate a multiplatform library’s skeleton in Kotlin. We can use these declarations for functions, classes, interfaces, enumerations, properties, and annotations. So far, the targets provide platform-specific implementations of this function. The common code does not care how it’s implemented.

kotlin desktop app

Here, as we can see, we are using a function declared as expected in the common source set.

kotlin desktop app

For instance, the common source set can declare a function as expected and the platform-specific source sets will be required to provide a corresponding function with the actual declaration: Kotlin multiplatform provides the mechanism of expected and actual declarations to achieve this objective. This is particularly useful for areas where certain common and reusable tasks are specialized and more efficient for leveraging platform-specific capabilities. However, in some cases, it may be desirable to define and access platform-specific APIs in common. So far, we’ve seen how Kotlin multiplatform programming allows us to reuse common code across platform-specific source sets.














Kotlin desktop app