sarriaroman / FabricPlugin

Fabric.io plugin for Cordova or Phonegap
MIT License
198 stars 159 forks source link

Error: Cannot find module 'xcode' #141

Closed pjorquera closed 5 years ago

pjorquera commented 5 years ago

This issue is fixed with Cordova version 8.1.2

Adding plugin to a project using Cordova CLI 8.1.x (8.1.0, 8.1.1) fails to install displaying the following error:

Installing "cordova-fabric-plugin" for ios
Failed to install 'cordova-fabric-plugin': Error: Cannot find module 'Xcode'

Steps to reproduce

$ cordova create myApp com.okode.myApp myApp
$ cordova platform add ios
$ cordova plugin add cordova-fabric-plugin --variable FABRIC_API_KEY=myAPIKey --variable FABRIC_API_SECRET=myAPISecret

Output error:

Installing "cordova-fabric-plugin" for ios
Failed to install 'cordova-fabric-plugin': Error: Cannot find module 'xcode'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Context.requireCordovaModule (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/Context.js:77:12)
    at Object.removeShellScriptBuildPhase (/Users/pjorquera/kk/myApp/plugins/cordova-fabric-plugin/hooks/lib/ios-helper.js:78:29)
    at module.exports (/Users/pjorquera/kk/myApp/plugins/cordova-fabric-plugin/hooks/after_plugin_add.js:21:19)
    at runScriptViaModuleLoader (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:196:18)
    at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:172:16)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:140:20
brotich commented 5 years ago

according to the cordava-lib changes, the Context.requireCordovaModule is currently being considered for deprecation and eventually removed in the next major version of cordava-lib.

relevant quote:

I can see the logic.
Since the workaround is pretty straight forward (npm install ) this can be easily overcome with a deprecation message & documentation.
A clear message of library xyz is relying on package abc which is no longer provided by cordova. Run npm install abc yourself could do magic to cordova developers hours of work and sanity...

source: https://github.com/apache/cordova-lib/issues/706#issuecomment-425314051

recommendation: the plugin should install the xcode npm package via npm install xcode and use it directly in the ios helper scripts

SteaM92 commented 5 years ago

unfortunately I am having the same issue but npm install xcode doesn't work for me :/ any help on that?

pjorquera commented 5 years ago

Fixed with Cordova version 8.1.2