Kotlin用于基于Cordova/Ionic的插件 [英] Kotlin for a Cordova/Ionic based plugin

查看:193
本文介绍了Kotlin用于基于Cordova/Ionic的插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将Kotlin用作Cordova插件的框架/语言?

is it possible to use Kotlin as a framework/language as a Cordova plugin?

第一个问题是它没有复制.kt文件,因为它查找* .java或* .xml

first issue is that it's not copying the .kt file, because it looks for *.java or *.xml

如果有人知道如何设置的参考?

if so anyone know a reference on how to setup?

推荐答案

最近,我一直在使用Cordova插件中的Kotlin,但是当我开始时,我也找不到关于如何创建Cordova的任何现有参考.使用Kotlin的插件.

Recently I've been working with Kotlin in Cordova plugins, but when I started out I also couldn't find any existing references as to how to create a Cordova plugin using Kotlin.

因此,我创建了一个示例插件,您可以将其用作模板:
https://github.com/dpa99c/cordova-plugin-hello-kotlin

So I've created an example plugin which you can use as a template:
https://github.com/dpa99c/cordova-plugin-hello-kotlin

如您所见,Cordova插件界面上的本机部分是在Kotlin中实现.

As you can see, the native part on the Cordova plugin interface is implemented in Kotlin.

因为当前cordova-android@7并不隐式支持Kotlin,所以该插件使用钩子脚本来设置由Cordova为Kotlin创建的本机Android项目,并且在卸载该插件时也从平台项目中删除.kt文件,因为当前cordova-android@7仅对.java文件执行此操作.

Because currently cordova-android@7 doesn't implicitly support Kotlin, the plugin uses hook scripts to set up the native Android project created by Cordova for Kotlin, and also to remove .kt files from the platform project when the plugin is uninstalled, since currently cordova-android@7 only does this for .java files.

但是它可以工作,您可以使用测试应用程序项目进行尝试

But it works and you can try it out with the test app project.

这篇关于Kotlin用于基于Cordova/Ionic的插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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