0
votes

I am using Visual Studio 2015 RTM, and I am working on a Cordova project. My project works fine for Android, but I cannot get it to build for IOS. I have figured out what the problem is, but I cannot figure out how to fix it.

When I build for IOS it is sending the build to the remote build agent installed on my Mac computer, but it is returning the following error:

Could not find module 'Q'. Please Go to Tools --> Options --> Tools for Apache cordova --> Cordova Tools --> Clear Cordova Cache and try building again.

Following it's suggestion and clearing the Cordova cache does not help. I did some research and have found that it is a bug in the cordova_ios library. Here is a link to the commit that fixed the error https://github.com/apache/cordova-ios/commit/ed272032878959c90eb28ccc1490e96fb7b69287.

Basically what the issue is that the check_reqs.js file is require 'Q' (uppercase) instead of 'q' (lowercase).

I can work around the problem (and confirm that this is the problem) by doing the following:

  • Copy my Cordova project over to my Mac computer.
  • At the command line add IOS as a Cordova platform.
  • Go to the /platforms/ios/cordova/lib/check_reqs.js file and change line 25 to be a lowercase 'q'.
  • Build and run the project on the Mac.

What I don't know is how to fix this in Visual Studio so I can build from Visual Studio? I have tried doing NPM updates on the computer that Visual Studio is installed on, but that has not fixed it. I have also tried to manually add the IOS platform to my project via the Cordova command line, and then changing the same file that I change on the Mac, but that does not fix it either.

It looks like this issue if fixed in the latest version of the cordova_ios library, I just cannot figure out how to get Visual Studio and/or the remote build agent on my Mac to use the latest version of the cordova_ios library.

Update It looks like this is a bug that other people are seeing with Cordova. There are discussion about it here and here. I can reproduce this on my Mac computer. If I create a new Cordova project and add the iOS platform and try to build it for iOS I receive this error. I can then correct the issue by opening the check_reqs.js file and changing the uppercase 'Q' to a lowercase 'q'. However when I build from Visual Studio it sends the project across to the Mac with the incorrect check_req.js file and the build fails. I cannot figure out how to correct this issue when doing a iOS build from Visual Studio.

4

4 Answers

1
votes

If your OSX machine has case a case sensitive filesystem you can hit this though a fix is in the works. (Most people do not turn on case sensativity.)

The fix you reference has not yet been released publicly. You can watch for a "platform" release here: http://cordova.apache.org/

Once the platform is released it is very likely a Cordova CLI update will also occur (ex: 5.1.2) so you can just update to that version via the config designer.

However, as an alternative you can add the following into your config.xml file to cause Cordova to use a different iOS platform version and then do a "clean" in VS to force it to take effect:

<engine name="ios" spec="3.9.0" />

3.8.0 is the currently released version.

A "DISCUSS" thread is already going for an iOS release - it should be out in the next couple of weeks.

You can try using the Git URI to get edge - but that could be buggy so exercise care:

<engine name="ios" spec="https://github.com/apache/cordova-ios.git" />
1
votes

I think we should simply do a patch release of Cordova with this bug fix. Will start a thread on the mailing list to see if a quick release is possible.

0
votes
0
votes

What version of node do you have installed on the MAC machine? I have 0.12.2 and the require(Q) gets satisfied without any errors. Can you try installing a newer version of Node? Let me know.