title: How to run a command in terminal from my Cocoa app?
body: <p>I want to use instrument to install the .app on my iOS simulator through my cocoa app.</p>
  
  <p>This is my first time developing a cocoa app and also NSTask. 
  NSTask requires a launch path which in my case is irrelevant as this command can be run from anywhere.
  This is the command i want to run:</p>
  
  <p>instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate  -w "iPad Retina (7.1 Simulator)" ""</p>
  
  <p>Currently i have this :</p>
  
  <pre><code>NSTask *task = [[NSTask alloc] init];
      [task setLaunchPath:@"/"];
  
      NSString * commandTorun = @"instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate  -w \"iPad Retina (7.1 Simulator)\" \"&lt;path to .app&gt;" ";
  
      NSArray *arguments = [NSArray arrayWithObjects:
                            @"-t" ,
                            [NSString stringWithFormat:@"%@", commandTorun],
                            nil];
  
      NSLog(@"Run command:%@",commandTorun);
  [task setArguments:arguments];
  [task launch];
  </code></pre>
  
  <p>Any help will be appreciated.</p>
  
  <p>Thanks,</p>