0

Getting errors in XCode for the following code within a Cordova plugin for Meteor 1.2:

PhoneRTCPlugin.swift
override init(webView: UIWebView) {
<code...>
super.init(webView: webView)
}

The errors are: Cannot override 'init' which as been marked unavailable 'init(webView:)' is unavailable: Deprecated in Cordova 3.9.2. Use plugininitialize method instead.

Thanks for your help.

user2330237
  • 1,629
  • 5
  • 20
  • 39

1 Answers1

2

It tells you that init(webView: UIWebView) isn't available because it was deprecated, use pluginInitialize instead

override func pluginInitialize() {
   peerConnectionFactory = RTCPeerConnectionFactory()
   RTCPeerConnectionFactory.initializeSSL()
}
jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
  • Thanks VERY much for your help with this, hope we can get it resolved. Unfortunately, when I try the code that you've included, I get two errors: on the override pluginInitialize like I get the error 'Consecutive declarations on a line must be separately by ;' and on the line that starts the class I get 'Class XXX has no initializers'. Thanks again. – user2330237 Nov 26 '15 at 14:57
  • sorry, I forgot the func part, I've never developed a plugin with swift, try again with the edit. Anyway, init(webView:) isn't removed yet, it will be removed on cordova ios 4 that hasn't been released yet, not sure which version meteor uses – jcesarmobile Nov 26 '15 at 16:00
  • Thanks again. That code does compile, but then I get another error, which is: Class PhoneRTCPlugin has no initializers. I tried adding: super.pluginInitialize(); but this didn't help. – user2330237 Nov 26 '15 at 19:29
  • try adding an empty init function ```init() { println("Hello") }``` – jcesarmobile Nov 26 '15 at 20:42
  • Unfortunately this did not remove the message Class PhoneRTCPlugin has no initializers. Do you know how to resolve this, or have examples to work from?? Thanks very much for your help. Much appreciated. – user2330237 Nov 27 '15 at 01:40
  • remove the init() and add a ```!``` at the end of the ```var peerConnectionFactory: RTCPeerConnectionFactory``` line ```var peerConnectionFactory: RTCPeerConnectionFactory!``` – jcesarmobile Nov 27 '15 at 09:26