Slide 1

Slide 1 text

A hitchhiker's guide to Kotlin MultiPlatform Accelerate your key learnings of modern Multiplatform app development with KMP Adit Lal GDE Android

Slide 2

Slide 2 text

Android GDE 🛠 Architect | Entrepreneur 🔊 Speaker 🌎 Globe Tro tt er 🍻 Beer enthusiast 🎯https:/ /androiddev.social/@aditlal 🔗aditlal.dev Adit GDE

Slide 3

Slide 3 text

Android GDE 🛠 Architect | Entrepreneur 🔊 Speaer 🌎 Globe Tro tt

Slide 4

Slide 4 text

Let’s Go https://app.sli.do/event/mJEpU8mPXKu8n6CDGzeZ35 or Goto slido.com Enter 1723179

Slide 5

Slide 5 text

a wild idea to build apps pops! develop for Android and iOS

Slide 6

Slide 6 text

a wild idea to build develop for An ‣ hire a team - Android and iOS ‣ de fi ne requirements ‣ plan roadmap for development ‣ develop and maintain and test apps ‣ production validation ‣ cross-check parity among both pla tf orms

Slide 7

Slide 7 text

native ~2x the team the cost time spent in meetings time spent on development time spent on testing time spent on bug fi xing a wild idea to build develop for An

Slide 8

Slide 8 text

a wild idea to build apps pops! develop for Android and iOS

Slide 9

Slide 9 text

a wild idea to build apps pops! develop for Android and iOS and web

Slide 10

Slide 10 text

native + web ~3x the team the cost time spent in meetings time spent on development time spent on testing time spent on bug fi xing a wild idea to build develop for An and web

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

how do we have the best of both worlds?

Slide 13

Slide 13 text

let’s fi nd a solution that works on all pla tf orms.

Slide 14

Slide 14 text

let’s fi nd a solution that works on all pla tf orms.

Slide 15

Slide 15 text

2006 2008 2011 2012 2013 2015 2017 2018 . . . . . . . Multipla tf Cross pla tf

Slide 16

Slide 16 text

Multipla tf orm Cross pla tf orm A system where a program targeting multiple platforms utilises platform-speci fi c code alongside shared common code. This setup allows leveraging native functionalities on each platform while maintaining a uni fi ed codebase for shared logic and features. A cross-platform application is a system that enables the deployment of an application using identical application code across different platforms.

Slide 17

Slide 17 text

how do we have the best of both worlds?

Slide 18

Slide 18 text

how do we have the best of both worlds?

Slide 19

Slide 19 text

Coroutines Null-Safety Extension-Functions Smart-Casts Delegated-Properties Versatility on the Server Side streamlined approach Open Source Modern Language Features Uni fi ed Codebase

Slide 20

Slide 20 text

Kotlin K otlin multipla tf orm Using kotlin in projects to target more than one pla tf orm

Slide 21

Slide 21 text

Kotlin multipla tf orm “Shared UI is a history of pain and failure. Shared logic is the history of computers.” - Kevin Galligan

Slide 22

Slide 22 text

Kotlin multipla tf Source - https://shorturl.at/xyAPX

Slide 23

Slide 23 text

Kotlin multipla tf orm /kot · lin mul · ti · plat · form / / kät' lin malti' platfôrm, kät'lin melti'platfôrm/ noun optional, natively-integrated, open-source, code sharing pla tf orm, based on the popular, modern language kotlin. facilitates non-ui logic availability on many pla tf orms.

Slide 24

Slide 24 text

Kotlin multipla tf orm Google Workspace Still migrating the Google Docs, Slides, Sheets, Drive, and Meet. The existing apps have billions of downloads and Google is in the process of migrating from their in-house J2ObjC transpiler to KMP. Source - https://shorturl.at/xyAPX

Slide 25

Slide 25 text

Kotlin multipla tf orm Reuse skills Plug and play Control your decisions Performance Production-ready Productivity

Slide 26

Slide 26 text

Kotlin multipla tf orm

Slide 27

Slide 27 text

Kotlin multipla tf orm

Slide 28

Slide 28 text

Kotlin multipla tf orm

Slide 29

Slide 29 text

Kotlin multipla tf orm

Slide 30

Slide 30 text

Kotlin multipla tf orm but how can they expect to communicate?

Slide 31

Slide 31 text

Kotlin multipla tf orm but how can they expect to communicate? expect declared at common module actual declared at android module declared at iOS module declared at ...

Slide 32

Slide 32 text

Kotlin multipla tf orm Platform specif i c names?

Slide 33

Slide 33 text

Kotlin multipla tf orm Pla tf orm | common

Slide 34

Slide 34 text

Kotlin multipla tf orm commonMain src/commonMain/sample/Platform.kt expect object Platform { val name: String }

Slide 35

Slide 35 text

Kotlin multipla tf orm src/commonMain/sample/Platform.kt expect object Platform { val name: String }

Slide 36

Slide 36 text

Kotlin multipla tf orm src/commonMain/sample/Platform.kt expect object Platform { val name: String } targets: android and iOS or macOS de fi ne actual on android de fi ne actual on iOS de fi ne actual on macOS

Slide 37

Slide 37 text

Kotlin multipla tf orm src/androidMain/sample/Platform.kt actual object Platform { actual val name: String = "Android" } pla tf orm-dependent code

Slide 38

Slide 38 text

Kotlin multipla tf orm pla tf orm-dependent code actual object Platform { actual val name: String = “iOS" } src/iOSMain/sample/Platform.kt

Slide 39

Slide 39 text

Kotlin multipla tf orm src/androidMain/sample/Platform.kt actual object Platform { actual val name: String = "Android" } pla tf orm-dependent code actual object Platform { actual val name: String = “iOS" } src/iOSMain/sample/Platform.kt

Slide 40

Slide 40 text

Kotlin multipla tf orm pla tf orm-dependent code actual object Platform { actual val name: String = “macOS” } src/macosMain/sample/Platform.kt

Slide 41

Slide 41 text

Kotlin multipla tf orm Backend too !! import io.ktor.* fun main() { embeddedServer(Netty, 9090) { routing { get("/hello") { call.respondText("Hello, API!") } } }.start(wait = true) } src/jvmMain/kotlin/Server.kt

Slide 42

Slide 42 text

Kotlin multipla tf orm Common code import io.ktor.client.* import io.ktor.client.request.* import io.ktor.client.statement.* class ApiClient { private val client = HttpClient() suspend fun getHello() : String { return client.get("http: / / localhost:9090/hello").bodyAsText() } src/commonMain/kotlin/ApiClient.kt

Slide 43

Slide 43 text

Kotlin multipla tf orm pla tf orm-dependent code lifecycleScope.launch { val response = ApiClient().getHello() / / Update UI with response } src/androidMain/sample/Platform.kt

Slide 44

Slide 44 text

Kotlin multipla tf orm

Slide 45

Slide 45 text

Kotlin multipla tf orm Actual needs to match because obviously it does

Slide 46

Slide 46 text

Kotlin multipla tf orm

Slide 47

Slide 47 text

Kotlin multipla tf orm

Slide 48

Slide 48 text

Common Kotlin Kotlin/JS JS code Kotlin/JVM JVM code Kotlin/Native Native code Kotlin multipla tf orm

Slide 49

Slide 49 text

Kotlin multipla tf orm How much do we share Multipla tf orm What makes most sense

Slide 50

Slide 50 text

Kotlin multipla tf orm - strong community - a lot of people are using kotlin nowadays - Google and JetBrains are pushing Kotlin exclusively - you can ask questions directly at h tt ps://kotlinlang.slack.com conclusions

Slide 51

Slide 51 text

Kotlin multipla tf orm - 🛠 Tooling 📦 Storage 🏗 Architecture 🔑 Crypto 🗃 Serializer - code and tools - 🍎 Compose UI 🧮 Arithmetic - 📋 Log 📱 Device 🔍 Analytics 📁 File ⏰ Date-Time - 🎨 Graphics 🛢 Resources - 🌎 Network 💉 Dependency Injection 🩺 Test 🚀 Language extensions ➿ Asynchronous 🧩 Service SDK 🔧 Utils

Slide 52

Slide 52 text

Kotlin multipla tf orm - 2x faster to develop your features business logic - 2x faster writing unit tests - One tech stack - consistency achieved across pla tf orms conclusions

Slide 53

Slide 53 text

Kotlin multipla tf orm - sta rt small, don’t try to reach 100% of shared logic - be extremely careful with all updates - IDEA, JDK, kotlin, libraries - everything. - keep versioning in mind Suggestions

Slide 54

Slide 54 text

Kotlin multipla tf orm Kotlin Slack Kotlin O ffi cial Kotlin Training Kotlin by: - h tt ps://jakewha rt on.com/presentations/ - h tt p://antonioleiva.com/kotlin Resources Pay attention to this

Slide 55

Slide 55 text

Kotlin multipla tf orm h tt ps://github.com/joreilly/PeopleInSpace h tt ps://github.com/joreilly/ClimateTraceKMP h tt ps://github.com/halcyonmobile/Multipla tf ormPlayground About Kotlin Multipla tf orm project with Swi ft UI, Jetpack Compose, Wear Compose, Compose for Desktop, Compose for Web and Kotlin/JS + React clients along with Ktor backend. Resources

Slide 56

Slide 56 text

Thats all folks! https:/ /linktr.ee/aldefy