Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introducing Kotlin Multiplatform in an existing mobile app - Workshop Edition | GDG Venezia

Introducing Kotlin Multiplatform in an existing mobile app - Workshop Edition | GDG Venezia

After discovering a new interesting technology or framework, you will probably start asking yourself how to integrate it into an existing project. That's because, the possibility of starting with a blank canvas is rare (not impossible, but rare).

This is also the case for Kotlin Multiplatform, which is getting more and more hype every day. And now, that the technology has become stable, it's the perfect time to start using it!
In this hands-on session, we will start with an existing Android and iOS application that "lives" in separate repositories, we will extract the business logic from the Android app and share it between the two apps with a Kotlin Multiplatform library. We will also cover how to distribute the library to the existing applications.
By the end of this workshop, you'll have a better understanding of what is needed to start using Kotlin Multiplatform in your existing projects.

Marco Gomiero

February 28, 2024
Tweet

More Decks by Marco Gomiero

Other Decks in Programming

Transcript

  1. 👨💻 Senior Android Developer @ Airalo Google Developer Expert for

    Kotlin Marco Gomiero @marcoGomier Introducing Kotlin Multiplatform in an existing mobile app workshop edition
  2. @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
  3. @marcoGomier “Classic” Cross Platform Solutions • All-in approach • Everything

    is shared, UI included • Different platforms have different patterns
  4. @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
  5. @marcoGomier Common Kotlin Kotlin/JVM Kotlin/JS Kotlin/Native JVM Android Browser NodeJS

    iOS macOS watchOS tvOS Linux Windows Mobile Kotlin/Wasm Browser Alpha
  6. @marcoGomier Common Kotlin Android App iOS App .aar XCFramework Android

    App Repository KMP Repository iOS App Repository Easier for existing projects
  7. @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!
  8. @marcoGomier Some gotchas • No namespaces • No default parameters

    • Enums are not Swift-friendly (no values) • Sealed classes are simple classes • Coroutines without cancellation • Flows
  9. @marcoGomier Swift Package Manager • Manual is boring and not

    scalable • Use some tooling and public artifactories
  10. @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”
  11. Bibliography / Useful Links • https: / / developer.apple.com/documentation/xcode/creating-a-multi-platform-binary-framework- bundle

    • https: / / devstreaming-cdn.apple.com/videos/wwdc/ 2019/416h8485aty341c2/416/416_binary_frameworks_in_swift.pdf • https: / / kotlinlang.org/docs/multiplatform-build-native-binaries.html • https: / / developer.apple.com/documentation/xcode/distributing-binary-frameworks-as-swift- packages • https: / / github.com/rickclephas/KMP-NativeCoroutines • https: / / skie.touchlab.co/ • https: / / github.com/luca992/multiplatform-swiftpackage • https: / / kmmbridge.touchlab.co/ • https: / / medium.com/geekculture/xcode-13-3-supports-spm-binary-dependency-in-private-github- release-8d60a47d5e45 • https: / / touchlab.co/xcodekotlin
  12. @marcoGomier Thank you! > Twitter: @marcoGomier > Github: prof18 >

    Website: marcogomiero.com > Mastodon: androiddev.social/@marcogom 👨💻 Senior Android Developer @ Airalo Google Developer Expert for Kotlin Marco Gomiero bit.ly/kmp-gdg-venezia