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

Challenges of Building Kotlin Multiplatform Libraries

Mohit S
March 25, 2022

Challenges of Building Kotlin Multiplatform Libraries

Mohit S

March 25, 2022
Tweet

More Decks by Mohit S

Other Decks in Programming

Transcript

  1. Android App class MainActivity : AppCompatActivity() { fun onCreate( ...

    ) { val greeting = Greeter().greet() textView.text = greeting } }
  2. Android App class MainActivity : AppCompatActivity() { fun onCreate( ...

    ) { val greeting = Greeter().greet() textView.text = greeting } }
  3. iOS App import SwiftUI import shared struct ContentView: View {

    var body: some View { Text(greet()) } }
  4. Android actual class Platform actual constructor() { actual val platform:

    String = 
 “Android ${android.os.Build.VERSION.SDK_INT}" }
  5. iOS import platform.UIKit.UIDevice actual class Platform actual constructor() { actual

    val platform: String = UIDevice.currentDevice.systemName() + " " + 
 UIDevice.currentDevice.systemVersion }
  6. iOS import platform.UIKit.UIDevice actual class Platform actual constructor() { actual

    val platform: String = UIDevice.currentDevice.systemName() + " " + 
 UIDevice.currentDevice.systemVersion }
  7. Summary • How to build KMM project • Shared Module

    Setup • Inside Shared Framework
  8. Choose Package Repository Search or enter package repository URL Name

    Last Updated Owner Projects(Github) KMMPackage Today 13:00 user
  9. Add Package to Project Choose package and targets Kind Add

    to Target KMMLibrary Library TestKMMLibrary Package Product
  10. Build Automation • Setup CI to create artifcats • Use

    artifacts from repository like Artifactory
  11. Common class CFlow internal constructor( val origin: Flow ) :

    Flow by origin { fun watch(block: (T) -> Unit) { } }
  12. Common class CFlow internal constructor( val origin: Flow ) :

    Flow by origin { fun watch(block: (T) -> Unit) { onEach { block(it) } launchIn(CoroutineScope( ... )) } }