Daniel Gartmann
Daniel Gartmann

Reputation: 13008

How Compatible is Apache Cordova with Swift?

I am about to start developing an iOS app that embeds a Cordova WebView and I would like to know how compatibles it is with the Swift programming language?

Upvotes: 0

Views: 1333

Answers (1)

Connor
Connor

Reputation: 64654

The cordova-ios library is written in Objective-C, but you can create Swift plugins. One thing to note is you must make your main plugin class accessible to 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)
    }
}

Upvotes: 1

Related Questions