-
Notifications
You must be signed in to change notification settings - Fork 986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cordova iOS 5.0.0 can not build without node_modules
present because of missing shelljs
for build phase script
#540
Comments
Some context on Took me a bit to understand that construct. |
Ok, talked to @erisu a bit about this: There are multiple options to fix this:
So option 3 it is I guess. |
I think my preference is for option 2. The script isn't complicated, and consists mostly of shelling out to run various commands, so there's no compelling reason in my mind for it to not just be a bash script. |
Good point. I wonder why this was changed in the first place... Will have to look at the blame and file history a bit. |
The file is here: https://github.com/apache/cordova-ios/blob/master/bin/templates/scripts/cordova/lib/copy-www-build-step.js History is here: https://github.com/apache/cordova-ios/blame/master/bin/templates/scripts/cordova/lib/copy-www-build-step.js Changes to the .js file are pretty limited and small:
#146 is the original PR that switched the script from bash to node, which resolved this issue: https://issues.apache.org/jira/browse/CB-8197
This is the last version of the shellscript before it was removed via that PR: https://github.com/apache/cordova-ios/blob/f8a5710cbafebfedc000335152777bc307e8b7ac/bin/templates/scripts/cordova/lib/copy-www-build-step.sh The PR didn't have the "lot of effort that goes into making sure it runs with the right node executable" yet, so this was added in a later PR. |
Yep, this is the PR that then complicated the |
And that is where my sleuthing ends, I am not qualified to decide if we should adapt the old .sh and just add the changes done to the .js or write a new shell script. In generall I have no idea how shell scripts work, so I am pretty lost. Can you take a shot at it please @dpogue? |
There didn't seem to be a compelling reason to keep this as JavaScript since it was primarily just shelling out to run various commands. By keeping it in bash, we can significantly simplify the invocation in the xcodeproj file and we can run it without a dependency on shelljs. I also moved it into a Scripts folder inside the project so that our xcodeproj file isn't reliant on the cordova/lib folder existing, and this particular script isn't actually a "lib" in the standard sense.
There didn't seem to be a compelling reason to keep this as JavaScript since it was primarily just shelling out to run various commands. By keeping it in bash, we can significantly simplify the invocation in the xcodeproj file and we can run it without a dependency on shelljs. I also moved it into a Scripts folder inside the project so that our xcodeproj file isn't reliant on the cordova/lib folder existing, and this particular script isn't actually a "lib" in the standard sense.
Bug Report
Problem
What is expected to happen?
The Cordova iOS project used to be able to build outside of a Cordova project. You could just copy
platforms/ios
and then use Xcode orxcodebuild
to build your app.What does actually happen?
You can not do that any more as the
shelljs
dependency is used by one of the build step scripts and is not present without the parentnode_modules
.Information
As soon as
node_modules
from the main project folder is missing (because it was either not created after a checkout from git, or because you copied over the iOS project fromplatforms/ios
to somewhere else, you get an error like this when trying to build withxcodebuild
or Xcode:(The error in Xcode directly is identical, as it just uses
xcodebuild
under the hood.)Known workaround
You can work around this problem by running
npm install shelljs
in your iOS project. This currently seems to be the only dependency required during build.How could this be solved?
Dependencies that are necessary for the scripts included in the project itself could/should be included in the actual project. (Alternatively there could be a package.json that is not installed by default, so it becomes at least possible to discover this when looking around)
Command or Code
Environment, Platform, Device
macOS 10.14.2 (Mojave)
Version information
Cordova CLI 8.1.1, Cordova iOS 5.0.0, Xcode 10.1 (10B61)
Checklist
The text was updated successfully, but these errors were encountered: