简体   繁体   中英

Kotlin Multiplatform Module Library

I've been working on some library which we want to ship for both Android and iOS, so far we were working for Android and iOS separately. Now considering that so many people started using KMM for their application, I just wanted to know if anyone has tried shipping a library created using Kotlin for both Android and iOS and what was their experience and the challenges that was faced during development and the integration of that library by the users.

Will it have any impact if I build my library using Kotlin 1.3.X version and user is on 1.2.X or 1.4.X?

The Android side will work like any other Android library with regards to Kotlin version. I'm not sure how well Kotlin 1.3 libraries work in Kotlin 1.4 or 1.2 on the JVM, but I assume "fairly well" at this point. I assume 1.4 using a 1.3 library would work totally fine.

For iOS, the framework you build and ship is its "own world", so iOS calling into it does not know or care that it's Kotlin, or what version of Kotlin it was built with.

However, if you ship klibs that other devs consume in native, that will need to align with versions differently, but it doesn't sound like you plan to do that.

I would highly recommend targeting 1.4.20 as the minimum for native. Not for any specific reason, other than native is under heavy development and each release adds important fixes and/or improvements. 1.3.x is pretty old from a KMM perspective. If you're only targeting Xcode frameworks, I'd build iOS with the latest stable Kotlin, as of today 1.4.32.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM