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

Lessons Learned from Using Kotlin Multiplatform internally

Lessons Learned from Using Kotlin Multiplatform internally

JB Lorenzo

August 27, 2019
Tweet

More Decks by JB Lorenzo

Other Decks in Programming

Transcript

  1. @bennegeek Poznan Berlin Pack 1 Pack 2 Pack 3 Pack

    4 Pack 5 Pack 6 Pack 7 Pack 8 Why?
  2. @bennegeek Poznan Berlin Pack 1 Pack 2 Pack 3 Pack

    4 Pack 5 Pack 6 Pack 7 Pack 8 Why? Why? Why?
  3. @bennegeek Poznan Berlin Pack 1 Pack 2 Pack 3 Pack

    4 Pack 5 Pack 6 Pack 7 Pack 8 Why? Why? Why? Why? Why? Why?
  4. @bennegeek Poznan Berlin Pack 1 Pack 2 Pack 3 Pack

    4 Pack 5 Pack 6 Pack 7 Pack 8 Why? Why? Why? Why? Why? Why?
  5. @bennegeek iOS * No control over Kotlin code * No

    knowledge of Kotlin/Kotlinx * Can we run tests * Is this a transition to Kotlin * Ktor Multiplatform is "experimental" * Concerns about coupling and syncing
  6. @bennegeek iOS * No control over Kotlin code * No

    knowledge of Kotlin/Kotlinx * Can we run tests * Is this a transition to Kotlin * Ktor Multiplatform is "experimental" * Concerns about coupling and syncing Write a detailed RFC
  7. @bennegeek iOS * Are there bigger projects? * Concerns about

    learning curve * Still No control on Kotlin code * Fear of bugs * Debugging * Performance concerns
  8. @bennegeek iOS * Are there bigger projects? * Concerns about

    learning curve * Still No control on Kotlin code * Fear of bugs * Debugging * Performance concerns Limit Scope of RFC Gather support from Android devs
  9. @bennegeek iOS * Scope is too small * Concerns about

    interop not being smooth * Concerns about memory, thread, error management
  10. @bennegeek iOS Swift/Objc iOS App Models Model to Domain Mappers

    Interfaces Network Calls (Ktor) Kotlin/MPP Model to I Netwo Sw
  11. @bennegeek iOS Swift/Objc iOS App Models Model to Domain Mappers

    Interfaces Network Calls (Ktor) Kotlin/MPP Model to I Netwo Sw
  12. @bennegeek iOS Models Model to Domain Mappers Interfaces Network Calls

    (Ktor) Kotlin/MPP Models Model to Domain Mappers Interfaces Network Calls (Ktor) Swift
  13. @bennegeek Technical Learnings Threading issues on the Main Thread https://blog.usejournal.com/the-dos-and-donts-of-mobile-development-with-kotlin-multiplatform-

    db7c098545c0 https://medium.com/@yuyaHorita/kotlin-native-ios-a1a73d7390fe https://proandroiddev.com/current-issues-with-kotlin-multiplatform-and-how-to-fix-them-5ae62822a546
  14. @bennegeek Technical Learnings Error Handling @Throws fun kotlinMethod(str: String) -

    (void)kotlinMethod:(NSString *)str error:(NSError * _Nullable * _Nullable)error;
  15. @bennegeek Technical Learnings Coroutines on iOS? // common internal expect

    val ApplicationScope: CoroutineScope ApplicationScope.launch { try { val ret = getCitySuggestion(query, isAdding, longitude, latitude) callback(ret, null) } catch (error: Error) { callback(null, error) } }
  16. @bennegeek Technical Learnings Coroutines on iOS? // ios/actual.kt internal actual

    val ApplicationScope: CoroutineScope = MainScope() private class MainDispatcher: CoroutineDispatcher() { override fun dispatch(context: CoroutineContext, block: Runnable) { dispatch_async(dispatch_get_main_queue()) { block.run() } } } internal class MainScope: CoroutineScope { private val dispatcher = MainDispatcher() private val job = Job() override val coroutineContext: CoroutineContext get() = dispatcher + job }
  17. @bennegeek What’s next for us * do Workshops for MPP

    * Pair iOS and Android devs * Wait for large companies to adopt Kotlin /MPP
  18. @bennegeek What you can do * Introduce Kotlin/MPP * Make

    an RFC in your team * Make devs familiar with both iOS and Android * Pair iOS and Android devs * Make your efforts public * Help Improve tooling Kotlin /MPP
  19. @bennegeek Thank you! Any Questions? Get in touch with us

    olxgroup.com tech.olx.com olxtechberlin [email protected] jblorenzo JB Lorenzo | #DCNYC19