我可以使用相同的kotlin代码库创建android,ios和web吗 [英] Can I create an android, ios and web with the same codebase of kotlin

查看:51
本文介绍了我可以使用相同的kotlin代码库创建android,ios和web吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 kotlin 创建了一个android应用,并且按需使其可以用于 Web-app 和IOS.因此,我在Google上搜索以找到一种实现此目的的方法,并且得到了类似 Kotlin的多平台之类的信息,阅读后我发现有一点也可以使用相同的代码库创建IOS应用.

I have created an android app with kotlin and it is on-demand to make it available for Web-app and IOS as well. So I searched on Google to find a way to do that and I got something like Kotlin for multiplatform and after reading that I got a point that it is possible to create an IOS app too with the same codebase.

但是我不知道相同的代码库也可以用于Web应用程序吗?或问题可能是是否有可能为具有相同代码库的所有3个平台制作一个应用程序?"

But I don't know that the same codebase can also work for the web app or not? Or the question can be that "Is it possible to make an app for all the 3 platforms with the same codebase?"

还是我应该切换到 Flutter ?但是,如果我切换到抖动模式,则必须从头开始迁移它.这将非常耗时.但是我已经听了,我们必须在Flutter上编写一次代码,然后在任何地方运行它.在使用Kotlin时,我必须针对不同的平台更改很多事情吗?

Or I should switch to Flutter? But if I switch to flutter then I have to start migrating it from scratch. Which would be so time consuming. But I have listened, that we have to write the code for once on flutter and run it anywhere. While with kotlin I have to change many things for different platforms?

我说的对吗?从长远来看,哪种方法更好?

推荐答案

理论上,使用 Kotlin Multiplatform ,您最多可以在平台之间获得〜80%共享代码.

With Kotlin Multiplatform, you can get up to ~80% shared code between platforms, theoretically.

是的,这意味着通常您的UI,但是对于每个平台,还必须重写其他特定于平台的内容.

Yes, this means that generally your UI, but other platform specific things also will have to be rewritten for every platform.

就您而言,我认为朝着这个方向前进是有意义的.您将不得不稍微修改一下kotlin代码,创建用于Web和iOS的UI,但是您将获得本机质量,并且可以更好地控制平台.至少如果我已经有kotlin代码库,这就是我会选择的,如果您还有其他问题,请告诉我

In your case, I think it makes sense to move towards this direction. You'll have to adapt your kotlin code a bit, make the UI for Web and iOS, but you'll get native quality, and more control over the platforms. At least this is what I would choose if I already have a kotlin codebase, let me know if you have more questions

这篇关于我可以使用相同的kotlin代码库创建android,ios和web吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆