Error: Cannot find module 'xcode'

Hi,

we got below error while implement  clevertap plugin in mobile app.

git url : https://github.com/SwapnilShinde89/clevertap-cordova-1

Please help for the same!


[2019-11-07T14:04:23.929Z] [INFO] Start processing job request...

[2019-11-07T14:04:23.935Z] [INFO] Start generating application...

[2019-11-07T14:04:23.936Z] [INFO] Template version: 5.1.13

[2019-11-07T14:04:23.936Z] [INFO] Build features: cordovaNoFetch - true

[2019-11-07T14:04:23.936Z] [INFO] Build features: buildTimeout - 20

[2019-11-07T14:04:23.937Z] [INFO] Creating a temporary folder for the application...

[2019-11-07T14:04:23.937Z] [INFO] Creating the required directory structure for your cordova application...

[2019-11-07T14:04:28.819Z] [INFO] Getting application resources...

[2019-11-07T14:04:28.835Z] [INFO] Processing application resources...

[2019-11-07T14:04:29.177Z] [INFO] Generating application assets...

[2019-11-07T14:04:31.887Z] [INFO] Applying configurations in the config.xml file...

[2019-11-07T14:04:31.894Z] [INFO] Applying advanced configurations in the config.xml file...

[2019-11-07T14:04:31.895Z] [INFO] Applying custom application icons...

[2019-11-07T14:04:31.898Z] [INFO] Applying custom application splashscreens...

[2019-11-07T14:04:31.898Z] [INFO] Applying application preferences...

[2019-11-07T14:04:31.905Z] [INFO] Writing your cordova preferences...

[2019-11-07T14:04:31.905Z] [INFO] Applying application accessList...

[2019-11-07T14:04:31.905Z] [INFO] Adding target platform...

[2019-11-07T14:05:35.583Z] [INFO] Applying plugins in the config.xml file...

[2019-11-07T14:05:35.583Z] [INFO] Plugin Id: https://github.com/OutSystems/cordova-plugin-contacts#3.0.1-OS1

[2019-11-07T14:05:35.584Z] [INFO] Plugin Action: add

[2019-11-07T14:06:03.080Z] [INFO] Plugin Id: https://github.com/Rareloop/cordova-plugin-app-version#v1.0.0

[2019-11-07T14:06:03.081Z] [INFO] Plugin Action: add

[2019-11-07T14:06:05.976Z] [INFO] Plugin Id: https://github.com/OutSystemsExperts/outsystems-app-store-launcher-plugin.git

[2019-11-07T14:06:05.977Z] [INFO] Plugin Action: add

[2019-11-07T14:06:08.345Z] [INFO] Plugin Id: https://github.com/OutSystems/cordova-plugin-geolocation.git#4.0.1-OS1

[2019-11-07T14:06:08.345Z] [INFO] Plugin Action: add

[2019-11-07T14:06:13.359Z] [INFO] Plugin Id: https://github.com/apache/cordova-plugin-file.git#4.3.3

[2019-11-07T14:06:13.360Z] [INFO] Plugin Action: add

[2019-11-07T14:06:17.087Z] [INFO] Plugin Id: https://github.com/SwapnilShinde89/clevertap-cordova-1.git

[2019-11-07T14:06:17.087Z] [INFO] Plugin Action: add

[2019-11-07T14:06:37.990Z] [ERROR]

You have been opted out of telemetry. To change this, run: cordova telemetry on.

No scripts found for hook "before_plugin_add".

Calling plugman.fetch on plugin "https://github.com/SwapnilShinde89/clevertap-cordova-1.git"

Fetching plugin "https://github.com/SwapnilShinde89/clevertap-cordova-1.git" via git clone

Running command: git clone --depth=1 https://github.com/SwapnilShinde89/clevertap-cordova-1.git /var/folders/6g/yzr1db091wgbfzcv9j3h1nwm0000gq/T/git/1573135578162

Command finished with error code 0: git clone,--depth=1,https://github.com/SwapnilShinde89/clevertap-cordova-1.git,/var/folders/6g/yzr1db091wgbfzcv9j3h1nwm0000gq/T/git/1573135578162

Repository "https://github.com/SwapnilShinde89/clevertap-cordova-1.git" checked out to git ref "master".

/tmp/build/source/plugins/clevertap-cordova"...

Plugin "clevertap-cordova" fetched.

Calling plugman.install on plugin "/Users/mabs01/NativeBuilder/builds/7e4fba12-25ba-4404-904d-52b313ffe0b2/source/plugins/clevertap-cordova" for platform "ios

Installing "clevertap-cordova" for ios

Running command: /Users/mabs01/NativeBuilder/builds/7e4fba12-25ba-4404-904d-52b313ffe0b2/source/platforms/ios/cordova/version

Command finished with error code 0: /Users/mabs01/NativeBuilder/builds/7e4fba12-25ba-4404-904d-52b313ffe0b2/source/platforms/ios/cordova/version

Finding scripts for "before_plugin_install" hook from plugin clevertap-cordova on ios platform only.

No scripts found for hook "before_plugin_install".

Install start for "clevertap-cordova" on ios.

PlatformApi successfully found for platform ios

Beginning processing of action stack for ios project...

"Embed Frameworks" Build Phase (Embedded Binaries) does not exist, creating it.

Adding custom framework to project... src/ios/CleverTapSDK.framework -> {"customFramework":true,"embed":true,"link":false,"sign":true}

Custom framework added to project. src/ios/CleverTapSDK.framework -> {"customFramework":true,"link":false,"sign":true,"embed":true}

Adding custom framework to project... src/ios/SDWebImage.framework -> {"customFramework":true,"embed":true,"link":false,"sign":true}

Custom framework added to project. src/ios/SDWebImage.framework -> {"customFramework":true,"link":false,"sign":true,"embed":true}

Adding non-custom framework to project... SystemConfiguration.framework -> {"customFramework":false,"embed":false,"link":true,"weak":false}

Non-custom framework added to project. SystemConfiguration.framework -> {"customFramework":false,"link":true,"weak":false}

Adding non-custom framework to project... CoreTelephony.framework -> {"customFramework":false,"embed":false,"link":true,"weak":false}

Non-custom framework added to project. CoreTelephony.framework -> {"customFramework":false,"link":true,"weak":false}

Adding non-custom framework to project... UIKit.framework -> {"customFramework":false,"embed":false,"link":true,"weak":false}

Non-custom framework added to project. UIKit.framework -> {"customFramework":false,"link":true,"weak":false}

Adding non-custom framework to project... CoreLocation.framework -> {"customFramework":false,"embed":false,"link":true,"weak":false}

Non-custom framework added to project. CoreLocation.framework -> {"customFramework":false,"link":true,"weak":false}

Action stack processing complete.

config file undefined requested for changes not found at /Users/mabs01/NativeBuilder/builds/7e4fba12-25ba-4404-904d-52b313ffe0b2/source/platforms/ios/undefined, ignoring

Install complete for clevertap-cordova on ios.

Finding scripts for "after_plugin_install" hook from plugin clevertap-cordova on ios platform only.

No scripts found for hook "after_plugin_install".

Adding clevertap-cordova to package.json

Saved plugin info for "clevertap-cordova" to config.xml

Executing script found in plugin clevertap-cordova for hook "after_plugin_add": plugins/clevertap-cordova/scripts/iosAfterPluginAdd.js

Error: Cannot find module 'xcode'


[2019-11-07T14:06:37.991Z] [ERROR] Build failed with the following error: An unexpected error has occurred while installing the Cordova plugins. Please try again. If the problem persists, contact OutSystems Support.

[2019-11-07T14:06:37.991Z] [INFO] Zipping application source...

[2019-11-07T14:07:06.915Z] [INFO] Application was not successfully generated!

[2019-11-07T14:07:06.919Z] [INFO] Execution time: 163658ms


Hi,

You're right, the problem is not directly your plugin but instead the dependency that you have from cordova-plugin-add-swift-support which in turn depends on "xcode".

Can you give it a try and use an older version of the cordova-plugin-swift-support plugi, specifically version 1.7.2 which packs the xcode dependency? Basically you just need to change on your plugin.xml from:

<dependency id="cordova-plugin-add-swift-support"/>

to:

<dependency id="cordova-plugin-add-swift-support@1.7.2"/>

Hopefully this solves the problem :)


Regards,

Nuno Verdasca

Hi Nuno,

Thank you for your reply.

This is my plugin.xml file from mentioned clevertap cordova plugin.

https://github.com/SwapnilShinde89/clevertap-cordova-1/blob/master/plugin.xml

But in above mentioned xml file we did not found below code which you mentioned in comments.

<dependency id="cordova-plugin-add-swift-support"/>

Can you guide me more for this solutions?

It will helpful for me.

Thank you!



Hi Swapnil,

I notice that your code is Objective-C, and not Swift, so you dont need actually to have support for:

<dependency id="cordova-plugin-add-swift-support@1.7.2"/>

From what i´ve seen, i presume this should be the problem, becouse you dont have any other dependencys.

hope it solves the problem.

regards,
Slavi

Hi Slavi,

Thank you for reply!

There is no dependency in plugin.xml from clevertap cordova plugin.

Still i have face the same issue.