简体   繁体   English

Kotlin 多平台模块库

[英]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.我一直在研究一些我们想为 Android 和 iOS 提供的库,到目前为止,我们分别为 Android 和 Z1B11ZCBDF6059929205EBF4 工作。 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.现在考虑到这么多人开始在他们的应用程序中使用 KMM,我只是想知道是否有人尝试过为 Android 和 iOS 提供使用 Kotlin 创建的库,以及他们在开发过程中面临的集成和挑战的经验和挑战该库由用户。

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?如果我使用 Kotlin 1.3.X 版本构建我的库并且用户使用 1.2.X 或 1.4.X,它会有什么影响吗?

The Android side will work like any other Android library with regards to Kotlin version.对于 Kotlin 版本,Android 端将像任何其他 Android 库一样工作。 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.我不确定 Kotlin 1.3 库在 JVM 上的 Kotlin 1.4 或 1.2 中的工作情况如何,但我认为“正确”。 I assume 1.4 using a 1.3 library would work totally fine.我假设使用 1.3 库的 1.4 完全可以正常工作。

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. 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.但是,如果您发布其他开发人员在本机中使用的 klib,则需要以不同的方式与版本保持一致,但这听起来不像您打算这样做。

I would highly recommend targeting 1.4.20 as the minimum for native.强烈建议将 1.4.20 定位为原生的最低要求。 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.从 KMM 的角度来看,1.3.x 已经很老了。 If you're only targeting Xcode frameworks, I'd build iOS with the latest stable Kotlin, as of today 1.4.32.如果您只针对 Xcode 框架,我将使用最新的稳定 Kotlin 构建 iOS,截至今天 1.4.32。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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