Open pablomaurer opened 7 years ago
Have you tryed adding @objc() annotations to your classes methods? I have resolved issues with this before.
e.g.
@objc(helloworld) class helloworld : CDVPlugin { @objc(hi) func hi (cmd: CDVInvokedUrlCommand) { print('Hi!') } }
Using @obj-c
in methods gives error @objc method name provides names for 0 arguments, but method has one parameter
Also searched for sample projects but all seem to use swift 2.
For swift 3 you'll need to change the function to the follow:
func sayHello(_ command: CDVInvokedUrlCommand)
It was frustrating to find the solution, but just adding _
makes everything magically work.
I was able to fix the issues with swift 3 by changing yourpluginname.swift to contain the following:
import Foundation
@objc(YourPluginNamePlugin) class YourPluginNamePlugin : CDVPlugin {
func sayHello(command: CDVInvokedUrlCommand) {
let message = "Hello !";
let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: message);
commandDelegate.send(pluginResult, callbackId:command.callbackId);
}
}
I ran
added Test Code:
Got Build Errors and probably because of Swift 3, Xcode suggested some changes i applied but still works not.
Getting Error
my progress:
Use Legacy Swift Language Version
toyes
to go ahead with Swift 2