I'm rewriting all plugins from an app from Objective-C to Swift. These plugins are called by Cordova. All the plugins work fine in Objective-C.
But when I try to run the app with the swift version plugin I got the following Error.
ERROR: Method 'getMAC2:' not defined in Plugin 'MACPlugin2'
I get this error in all method of any plugin that I rewrite to Swift.
Look this plugin code example:
import Foundation
@objc(MACPlugin2)
class MACPlugin2 : CDVPlugin {
    func getMAC2(command : CDVInvokedUrlCommand){
        print("########## ENTER MACPLUGIN 2 ###########")
    }
}
Someone have an idea of what are happening?
Best,
Flávio
Adding the _ before the parameter was not enough for me. I had to add a @objc(test:) before the method as well.
@objc(test:)
func test(_ command: CDVInvokedUrlCommand) {
    // whatever
}
                        My example was as following, without _ it was not working!! Notice: This solution is a fix for Swift 3
@objc(LibCDVP) class LibCDVP : CDVPlugin {
    func echo(_ command: CDVInvokedUrlCommand) {
        print("method call OK!")
        let msg = command.arguments[0] as? String ?? ""
        let pluginResult = CDVPluginResult(
            status: CDVCommandStatus_OK,
            messageAs: msg + ",ECHO"
        )
        self.commandDelegate!.send(
            pluginResult,
            callbackId: command.callbackId
        )
    }
}
                        Dan, was right, I just added _ before the parameters.
Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With