0
votes

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?)

Updated

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 -

** BUILD FAILED **

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?

Thanks!!

2

2 Answers

0
votes

I did this plugin in order to bring the swift support in Cordova projects : https://github.com/akofman/cordova-plugin-add-swift-support

You can have a try with it and also read the following article which is a good tutorial.

0
votes

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 ..}