KKb KKb - 11 months ago 116
Swift Question

How to create Cordova iOS Phonegap Plugin (Swift)?

I need to create cordova iOS phoneGap plugin using swift. I don't have any idea about this.I visited the link - "http://cordova.apache.org/docs/en/latest/guide/platforms/ios/plugin.html"
But this seems vague to me, there not step by step detailed description. Please help me out with this.(Any tutorial with step by step instructions?)


I have used tutorial - "http://moduscreate.com/writing-a-cordova-plugin-in-swift-for-ios/" and followed the same steps with the same code but got stuck while running command "cordova build ios" with the following error -


The following build commands failed:
CompileXIB TestApp/Classes/MainViewController.xib
(1 failure)
Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/kirti/testapp/platforms/ios/cordova/build-debug.xcconfig,-project,TestApp.xcodeproj,-target,TestApp,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,build,CONFIGURATION_BUILD_DIR=/Users/kirti/testapp/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/kirti/testapp/platforms/ios/build/sharedpch

Please help me out.I do not understand what's the problem is?


Answer Source

I have solved the problem finally.The reason of error "Build Failed" was due to the version of swift.In swift 3, you need to add "@objc" before function name.In my case, it's like -

@objc(echo:)func echo(command: CDVInvokedUrlCommand) { //...enter code here ..}