-->

How to run Grunt tasks during Xcode build phase?

2020-07-18 02:55发布

问题:

I am developing a web application, which includes GruntJS build tasks. I deploy it using Phonegap/Cordova in the Xcode IDE.

I would like to integrate the grunt build process into my Xcode project to simplify running the project. Ideally Xcode should run all the processes that I manually invoke using the Grunt CLI beforehand.

My Gruntfile.js lies within the root Xcode project directory. I have a local grunt install (0.4.0rc4) in node_modules and grunt-cli installed globally.

project
- multiple project dirs ...
- node_modules
- www-src
- www
  project.xcodeproj
  Gruntfile.js

I have tried adding a custom Run script - build phase to my Xcode project with a command as simple as "grunt" which returns "grunt: command not found" during build. Clearly more effort is needed to reference grunt and/or the proper target directory.

回答1:

Nice setup Gregor :-) I had exact same setup for my previous project. Here is how I setup my custom script in Xcode Build Phases:

cd "${PROJECT_DIR}"
PATH=${PATH}:/usr/local/bin
grunt

Hope this helps you :-)