简体   繁体   English

Apache Cordova与Swift的兼容性如何?

[英]How Compatible is Apache Cordova with Swift?

我将要开始开发一个嵌入Cordova WebView的iOS应用程序,我想知道它与Swift编程语言的兼容性如何?

The cordova-ios library is written in Objective-C, but you can create Swift plugins. cordova-ios库是用Objective-C编写的,但是您可以创建Swift插件。 One thing to note is you must make your main plugin class accessible to Objective-C. 需要注意的一件事是您必须使您的主插件类可被Objective-C访问。 See the example here . 请参阅此处的示例。

@objc(HWPHello) class Hello : CDVPlugin {
    func greet(command: CDVInvokedUrlCommand) {
        var message = command.arguments[0] as String

        var pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAsString: "Hello \(message)")
        commandDelegate.sendPluginResult(pluginResult, callbackId:command.callbackId)
    }
}

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

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