@marcoGomier
Marco Gomiero
Senior Android Developer @ Airalo
Google Developer Expert for Kotlin
Introducing
Kotlin Multiplatform in
an existing mobile app
workshop edition
Slide 2
Slide 2 text
@marcoGomier
Prerequisites
• Download Android Studio and the Kotlin Multiplatform Plugin
• Download Xcode
You can check if your system is ready for Kotlin Multiplatform with
kdoctor: https:
//
github.com/Kotlin/kdoctor
Slide 3
Slide 3 text
@marcoGomier
bit.ly/kmp-existing-app-workshop
Slide 4
Slide 4 text
@marcoGomier
What is Kotlin Multiplatform?
Slide 5
Slide 5 text
@marcoGomier
“Classic” Cross Platform Solutions
• All-in approach
• Everything is shared, UI included
Slide 6
Slide 6 text
@marcoGomier
Kotlin Multiplatform
• Incremental approach
• You choose what to share (even UI, if you want)
Slide 7
Slide 7 text
@marcoGomier
Photo by Erwan Hesry on Unsplash
💡 Create a library!
Slide 8
Slide 8 text
@marcoGomier
Common Kotlin
Kotlin/JVM Kotlin/JS
Kotlin/Native
JVM
Android
Browser
NodeJS
iOS
macOS
watchOS
tvOS
Linux
Windows
Supported Platforms
Kotlin/Wasm
Browser
Alpha
Slide 9
Slide 9 text
@marcoGomier
Common Kotlin
Kotlin/JVM Kotlin/JS
Kotlin/Native
JVM
Android
Browser
NodeJS
iOS
macOS
watchOS
tvOS
Linux
Windows
Mobile
Kotlin/Wasm
Browser
Alpha
@marcoGomier
Swift Package Manager
• Based on git
• Configured with a Package.swift file
• Semantic versioning (e.g. 1.2.3) with git tags
• Can contain code or binaries
• Can be local or remote, it’s git!
Slide 24
Slide 24 text
@marcoGomier
Code Time 🧑💻
Slide 25
Slide 25 text
@marcoGomier
shared
iosApp
Framework
iOS
Kotlin
Objective-C
Swift
->
->
Slide 26
Slide 26 text
@marcoGomier
Some gotchas
• No namespaces
• No default parameters
• Enums are not Swift-friendly (no values)
• Sealed classes are simple classes
• Coroutines without cancellation
• Flows
@marcoGomier
Swift Package Manager
https://twitter.com/kpgalligan/status/1723364386046173493
Slide 29
Slide 29 text
@marcoGomier
Code Time 🧑💻
Slide 30
Slide 30 text
@marcoGomier
Conclusions
• You choose what to share (even UI, if you want)
• Validate the process with “little” effort
• Find the best (for you) approach/infrastructure
• Then you can go bigger and share more “features”
Slide 31
Slide 31 text
@marcoGomier https://touchlab.co/kmp-teams-use-source
More reading
Slide 32
Slide 32 text
@marcoGomier
Thank you!
> Twitter: @marcoGomier
> Github: prof18
> Website: marcogomiero.com
> Mastodon: androiddev.social/@marcogom
> BlueSky: @marcogomiero.com
Marco Gomiero
Senior Android Developer @ Airalo
Google Developer Expert for Kotlin