当前位置: 首页 > 软件库 > 手机/移动开发 > >

KotlinMultiPlatform

授权协议 GPL-3.0 License
开发语言 Kotlin
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 窦凯定
操作系统 Android
开源组织
适用人群 未知
 软件概览

Kotlin-Multiplatform (Android, iOS, JS & JVM Desktop App)

This example shows how to create a simple Android/iOS/JVM/JS project sharing some Kotlin code. This app saves on a local database your favourites locations and get the current weather of them from OpenWeatherMap.

In this app we share common code for both platforms (Android/iOS) to get data from an API (in this case OpenWeatherMap). The libraries that we use are:

Tests:

  • MockK: mocking library for Kotlin

Android App - Master Branch

With this app you can get the weather of your locations using KTor:

And add and save on SQLDelight database your favourite locations:

iOS App

Open XCode and select the project:

JVM - Desktop App

To execute this version as desktop app, you have to execute this code on your console:

./gradlew JavaFxApp:run

By default the JDBC SQLite is created in memory. If you want to persist your database in your disk, you have to indicate the path when you create the database driver:

SQLDriver.kt
JdbcSqliteDriver("jdbc:sqlite:$your_database_path")

JS App

If you want to launch a web to get the weather you can try executing the next commands:

./gradlew JsApp:run
./gradlew BackEnd:run
--> localhost:8080

Current weather is not shown when you launch the browser? If you have this problem (Module not found: Error: Can't resolve 'core-js/features/object/assign') try to reinstall the node module core-js:

npm install core-js

I have followed these examples:

https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html

https://www.raywenderlich.com/1022411-kotlin-multiplatform-project-for-android-and-ios-getting-started

https://proandroiddev.com/kotlin-multiplatform-very-beginners-guide-part-3-database-e34c92daf41c

  • 操作系统 操作系统版本:最高支持 Monterey ,最低支持 Big Sur 验证: 左上角 ---> 关于本机 ---> macOS Monterey ## iOS 环境 1. Xcode 支持 13.2.1 ,可直接通过 Apple Store 更新 验证 $ xcodebuild -version Xcode 13.2.1 Build version 13C100 2. Cocoap

  • 前言 当下市场上的跨端解决方案, 不管使用的是React Native, Flutter 还是Weex, 常见的项目组成是, 业务UI界面由上述框架解决, 而涉及不论是性能问题, 还是平台通用共享逻辑问题, 我们更侧重于原生开发, 而这一块我们必不可免需要至少两个原生开发同学通过沟通和开发统一Native层的功能逻辑, 而针对于这些原生通用代码, 现有常见的解决方案还是主要通过传统的C/C++来解

  • 依赖 不建议在windows,因为ios app只能在mac下开发(垃圾苹果) andrioid studio + plugin:kotlin multiplatform xcode13+ brew install cocoapods kdoctor kdoctor检查依赖 kt基础 fun main() { val info = Info("xiaosaobei",20) in

  • 前言 多年开发常用的日期时间转换工具打包成库,分享出来。 版本1.2开始,本库已经改造成kotlin跨平台项目,目前支持JVM、JS,native, 但是由于一直在用的 jitpack.io 不支持JVM以外的打包环境,暂时没有其他的在线库生成,只能自己下载项目下来然后执行build。 使用 1 Add it in your root build.gradle at the end of repo