I'm working with Ionic which has a command line interface. I would like to create a small Mac app that helps to execute certain commands.
In the terminal I cd Users/me/Desktop/Repos/ionic-project/myApp
After changing I would e.g. ionic run
NSTask *task = [[NSTask alloc]init];
task.launchPath = @"/bin/bash";
task.currentDirectoryPath = @"cd Users/me/Desktop/Repos/ionic-tryouts/myApp";
task.arguments = @[@"ionic run"];
[task launch];
But this gives me 'working directory doesn't exist.' I've already read quite some threads here on SO. Whats my mistake?
EDIT:
Thanks Christik for the detailed answer. I now have this code:
NSTask *task = [[NSTask alloc]init];
task.launchPath = @"/usr/local/bin/ionic";
task.currentDirectoryPath = @"/Users/me/ionic-tryouts/myApp";
task.arguments = @[@"run"];
[task launch];
Now I get the following error: env: node: No such file or directory
. I guess this comes from a problem, that node.js isn't found (ionic is build on top of node). I found this issue - a missing symlink with the right name might be the cause. But setting the symlink for node didn't help. Any ideas?
EDIT2: I gave Christik the correct answer, even though I couldn't finally get it to work. I'm still investigation. Maybe it's the node installation thats wrong.
EDIT3: I saw some posts that mentioned that it might be better, if node was re-installed by homebrew since homebrew installs it without sudo. Short comment: didn't help