π¨π» Senior Android Developer @ Airalo
Google Developer Expert for Kotlin
Marco Gomiero
@marcoGomier
Introducing
Kotlin Multiplatform in
an existing mobile app
workshop edition
Slide 2
Slide 2 text
@marcoGomier
bit.ly/kmp-workshop-devfestberlin
Slide 3
Slide 3 text
@marcoGomier
Agenda
β’ Download Android Studio and the Kotlin Multiplatform Plugin
β’ Download Xcode
β’ Quick intro about Kotlin Multiplatform
β’ Start from an Android and iOS native app - that lives in separate repositories
β’ Extract the business logic into a new KMP library
β’ [Manually and locally] Deploy the library
β’ Replace the business logic on Android and iOS with the KMP library
β’ [BONUS] iOS API enhancements
β’ [BONUS] How to deploy in a scalable way
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
β’ Different platforms have different patterns
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
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
@marcoGomier
Swift Package Manager
β’ Configured with a Package.swift file
β’ Based on git
β’ Semantic versioning (e.g. 1.2.3) with git tags
β’ Can contain code or binaries
β’ Can be local or remote, itβs git!
Slide 26
Slide 26 text
@marcoGomier
Code Time π§π»
Slide 27
Slide 27 text
@marcoGomier
Kotlin
->
Obj-c
->
Swift
Slide 28
Slide 28 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
Slide 29
Slide 29 text
@marcoGomier
Code Time π§π»
Slide 30
Slide 30 text
@marcoGomier
Swift Package Manager
β’ Manual is boring and not scalable
Slide 31
Slide 31 text
@marcoGomier
Code Time π§π»
Slide 32
Slide 32 text
@marcoGomier
Swift Package Manager
β’ Manual is boring and not scalable
β’ Use some tooling and public artifactories
Slide 33
Slide 33 text
@marcoGomier
Conclusions
β’ You choose what to share (even UI, if you want)
β’ Validate the process with βlittleβ effort
β’ Then you can go bigger and share more βfeaturesβ