Cordova-plugin-iosrtc: Can't resolve 'cordova/exec'

Created on 9 Apr 2020  路  18Comments  路  Source: cordova-rtc/cordova-plugin-iosrtc

Expected behavior

I expect the plugin to compile.

Observerd behavior

After installing the plugin (cordova plugin add cordova-plugin-iosrtc), I run ionic serve and compilation fails with the error:

ERROR in ./node_modules/cordova-plugin-iosrtc/js/iosrtc.js
Module not found: Error: Can't resolve 'cordova/exec' in '/Users/../node_modules/cordova-plugin-iosrtc/js'

Steps to reproduce the problem

run either:

  1. ionic serve
  2. ionic cordova build ios

Platform information

  • Cordova version: 9.0.0 ([email protected])
  • Plugin version: 6.0.9
  • iOS version: 13.1
  • Xcode version: 11.4
help wanted

All 18 comments

This is most likely an issue with your enviroment.

The automated system validated the last build 3 days ago, including ionic build:

All I can tell you is:

  • reinstall cordova
  • reinstall ionic
  • try cordova@8

Cordova 9 is know to have many issues and the most stable cordova is [email protected].
Can you provide the ionic version you are using.

Finally there is a similar issue on ionic repository, most likely ionic broke they shit again would not be the first time: https://github.com/ionic-team/ionic-app-scripts/issues/1176

Did you install the plugin this way ?

ionic cordova plugin add cordova-plugin-iosrtc

Thanks for getting back to me!

I will try the reinstalls and see if that yields better results. I'll also install cordova 8.

I added the plugin using:

ionic cordova plugin add cordova-plugin-iosrtc

@TravBradfield Can you provide the ionic version you are using?

Ionic:

Ionic CLI : 6.5.0 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.0.7
@angular-devkit/build-angular : 0.803.26
@angular-devkit/schematics : 8.3.26
@angular/cli : 8.3.26
@ionic/angular-toolkit : 2.2.0

Cordova:

Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : android 8.1.0, ios 5.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 4 other plugins)

Utility:

cordova-res : not installed
native-run : 1.0.0

System:

ios-sim : 8.0.2
NodeJS : v12.16.2 (/usr/local/bin/node)
npm : 6.14.4
OS : macOS Catalina
Xcode : Xcode 11.4 Build version 11E146

I've reinstalled cordova, I'm now running:
$ cordova -v

8.1.2 ([email protected])

You still have the issue @TravBradfield ?
If yes, I will updat Travis build to test.

@hthetiot Yes I do still have the issue... Please double check for me?

@TravBradfield ok I will check your enviroment, but i want you to understand that it's failing because you may use a more modern ionic and cordova setup than the current supported enviroment.

@hthetiot

Thanks for your help! Turns out I was importing the plugin incorrectly. When I changed it to the correct method of importing it works correctly.

Sorry for the trouble! Plugin is working spot on.

ahah I knew it, what did you do ?
How did you inmport it instead and how it you import it successfully ?

Build is running now here with you setup:

Let see what travis says oce completed:

Tell me what you where doing wrong so we can all learn.
Also make sure to read that part for publishing on the store: https://github.com/cordova-rtc/cordova-plugin-iosrtc/blob/master/docs/Building.md#apple-store-submission

Happy RTC.

I was importing it like an @ionic-native plugin. Which is not correct.

I was doing:

import { iostrc } from 'cordova-plugin-iostrc'.

I changed it to

declare var cordova:

cordova.plugins.iosrtc

Ah yes, I see :)
Thank you, I will try to add to documentation may be we can also work on making it es6 module soon (in v7+)

Thanks very much man! Your plugin is making a big difference already. I appreciate your fast responses!!

Here is what I recommend @TravBradfield to just use the WebRTC globals shim and not the plugin API methods.

declare var cordova:
// Expose WebRTC Globals
if (cordova && cordova.plugins && cordova.plugins.iosrtc) {
  cordova.plugins.iosrtc.registerGlobals();
  //cordova.plugins.iosrtc.debug.enable('*', true);
  cordova.plugins.iosrtc.turnOnSpeaker(true);
  cordova.plugins.iosrtc.requestPermission(true, true, function (result) {
    console.log('requestPermission.result', result);
  });
}

Yeah that's exactly what I'm using. I built a JS video call app, but it wasn't working on iOS. By implementing cordova.plugins.iosrtc.registerGlobals(); the job was almost completely done.

Was good anyway, I needed to update travis ionic build, travis is happy now :)

Was this page helpful?
0 / 5 - 0 ratings