Tengo un proyecto macOS usando Objective-C. Básicamente, soy nuevo en la creación de aplicaciones para macOS. No hago Objective-C ni Swift, pero tengo un archivo nodejs que necesito ejecutar y no estoy seguro de cómo hacerlo.
#import <Cocoa/Cocoa.h> int main(int argc, const char *argv[]) { - (NSString *)runCommand:(NSString *)commandToRun { NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:@"/nodefile.js"]; NSArray *arguments = [NSArray arrayWithObjects: @"-c" , [NSString stringWithFormat:@"%@", commandToRun], nil]; NSLog(@"run command:%@", commandToRun); [task setArguments:arguments]; NSPipe *pipe = [NSPipe pipe]; [task setStandardOutput:pipe]; NSFileHandle *file = [pipe fileHandleForReading]; [task launch]; NSData *data = [file readDataToEndOfFile]; NSString *output = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; return output; } return NSApplicationMain(argc, argv); }