Skip to content

Commit

Permalink
refactor(docs.topics.multiplatform): add notes
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredo-toledano committed Aug 25, 2024
1 parent b57b635 commit 7c77389
Showing 1 changed file with 37 additions and 50 deletions.
87 changes: 37 additions & 50 deletions docs/topics/multiplatform/multiplatform.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,61 @@
[//]: # (description: Kotlin Multiplatform allows creating cross-platform apps for desktop, web, and mobile devices.
Share application logic while keeping native user experience.)

The Kotlin Multiplatform technology is designed to simplify the development of cross-platform projects. It reduces time
spent writing and maintaining the same code for [different platforms](#kotlin-multiplatform-use-cases)
while retaining the flexibility and benefits of native programming.
* allows
* simplifying the development of cross-platform projects
* reduces time spent
* Reason: 🧠same code for [different platforms](#kotlin-multiplatform-use-cases) 🧠
* retain the flexibility and benefits of native programming

![Kotlin Multiplatform](kotlin-multiplatform.svg){width=700}

## Kotlin Multiplatform use cases

### Android and iOS applications

Sharing code between mobile platforms is a major Kotlin Multiplatform use case. With Kotlin Multiplatform,
you can build cross-platform mobile applications that share code between Android and iOS projects to implement networking,
data storage and data validation, analytics, computations, and other application logic.

Check out the [Get started with Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-create-first-app.html) and
[Create a multiplatform app using Ktor and SQLDelight](https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-ktor-sqldelight.html) tutorials,
where you will create applications for Android and iOS that include a module with shared code for both platforms.

Thanks to [Compose Multiplatform](https://www.jetbrains.com/lp/compose-multiplatform/),
a Kotlin-based declarative UI framework developed by JetBrains,
you can also share UIs across Android and iOS to create fully cross-platform apps:

![Sharing different levels and UI](multiplatform-compose.svg){width=600}

Check out the [Create a Compose Multiplatform app](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-multiplatform-create-first-app.html)
tutorial to create your own mobile application with UIs shared between both platforms.
* allows
* building cross-platform mobile applications / sharing code to
* implement networking,
* data storage
* data validation,
* analytics,
* computations,
* other application logic
* Check
* [Get started with Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-create-first-app.html)
* [Create a multiplatform app using Ktor and SQLDelight](https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-ktor-sqldelight.html)
* Compose Multiplatform
* [Compose Multiplatform](https://www.jetbrains.com/lp/compose-multiplatform/)
* [Create a Compose Multiplatform app](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-multiplatform-create-first-app.html)

### Multiplatform libraries

Kotlin Multiplatform is also helpful for library authors. You can create a multiplatform library with common code and its
platform-specific implementations for JVM, web, and native platforms. Once published, a multiplatform library can be used
as a dependency in other cross-platform projects.

See the [Publish a multiplatform library](multiplatform-publish-lib.md) for more details.
* == multiplatform library / common code + platform-specific implementations for JVM, web, and native platforms
* [Publish a multiplatform library](multiplatform-publish-lib.md)
* once it's published -> can be used as a dependency | other cross-platform projects

### Desktop applications

Compose Multiplatform helps share UIs across desktop platforms like Windows, macOS, and Linux. Many applications,
including the [JetBrains Toolbox app](https://blog.jetbrains.com/kotlin/2021/12/compose-multiplatform-toolbox-case-study/),
have already adopted this approach.

Try this [Compose Multiplatform desktop application](https://github.com/JetBrains/compose-multiplatform-desktop-template#readme)
template to create your own project with UIs shared among desktop platforms.
* -- thanks to -- Compose Multiplatform
* Check
* [Compose Multiplatform desktop application](https://github.com/JetBrains/compose-multiplatform-desktop-template#readme)
* [JetBrains Toolbox app](https://blog.jetbrains.com/kotlin/2021/12/compose-multiplatform-toolbox-case-study/)

## Code sharing between platforms

Kotlin Multiplatform allows you to maintain a single codebase of the application logic for [different platforms](multiplatform-dsl-reference.md#targets).
You also get advantages of native programming, including great performance and full access to platform SDKs.
* ways
* among [all platforms / used | your project](multiplatform-share-on-platforms.md#share-code-on-all-platforms)
* among [some platforms / included | your project](multiplatform-share-on-platforms.md#share-code-on-similar-platforms)

Kotlin provides the following code sharing mechanisms:
![Code shared across different platforms](kotlin-multiplatform-hierarchical-structure.svg){width=700}

* Share common code among [all platforms](multiplatform-share-on-platforms.md#share-code-on-all-platforms) used in your project.
* Share code among [some platforms](multiplatform-share-on-platforms.md#share-code-on-similar-platforms) included in your project to reuse much of the code in similar platforms:

![Code shared across different platforms](kotlin-multiplatform-hierarchical-structure.svg){width=700}

* If you need to access platform-specific APIs from the shared code, use the Kotlin mechanism of [expected and actual
declarations](multiplatform-expect-actual.md).
* if, from the shared code, you -- need to access -- platform-specific APIs , -> use [expected and actual declarations](multiplatform-expect-actual.md)
* Check
* [different platforms](multiplatform-dsl-reference.md#targets)

## Get started

* Begin with the [Get started with Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-create-first-app.html) if you want to create iOS and Android applications with shared code
* Explore [sharing code principles and examples](multiplatform-share-on-platforms.md) if you want to create applications or libraries targeting other platforms

> New to Kotlin? Take a look at [Getting started with Kotlin](getting-started.md).
>
{type="tip"}

### Sample projects

Look through [cross-platform application samples](https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-samples.html) to understand how Kotlin Multiplatform works.
* Check
* [Get started with Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-create-first-app.html)
* [sharing code principles and examples](multiplatform-share-on-platforms.md)
* [cross-platform application samples](https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-samples.html)

0 comments on commit 7c77389

Please sign in to comment.