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

Introducing Kotlin Multiplatform in an existing...

Introducing Kotlin Multiplatform in an existing mobile app - Workshop Edition | Android Developers Italia

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

March 12, 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 • 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 • [Locally and remote] Deploy the library • Replace the business logic on Android and iOS with the KMP library • [BONUS] How to deploy in a scalable way • [BONUS] iOS API enhancements
  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 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”
  10. Bibliography / Useful Links • https: // docs.github.com/en/actions/publishing-packages/publishing-java-packages-with-gradle • https:

    // github.com/orgs/community/discussions/26328#discussioncomment-3251485 • https: // github.com/orgs/community/discussions/26634 • 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: // touchlab.co/skie-migration?ti=4B0F129C5D944E54B60B31FE35 • https: // medium.com/@aoriani/list/writing-swiftfriendly-kotlin-multiplatform-apis-c51c2b317fce • https: // blog.devgenius.io/dependancy-management-for-ios-27dd681d7ea0 • https: // github.com/luca992/multiplatform-swiftpackage • https: // kmmbridge.touchlab.co/ • https: // touchlab.co/kmmbridge-quick-start • https: // medium.com/geekculture/xcode-13-3-supports-spm-binary-dependency-in-private-github-release-8d60a47d5e45 • https: // touchlab.co/xcodekotlin
  11. @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