objective c - How to run a command in terminal from my Cocoa app? -
objective c - How to run a command in terminal from my Cocoa app? -
i want utilize instrument install .app on ios simulator through cocoa app.
this first time developing cocoa app , nstask. nstask requires launch path in case irrelevant command can run anywhere. command want run:
instruments -t /applications/xcode.app/contents/applications/instruments.app/contents/plugins/automationinstrument.xrplugin/contents/resources/automation.tracetemplate -w "ipad retina (7.1 simulator)" ""
currently have :
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)\" \"<path .app>" "; nsarray *arguments = [nsarray arraywithobjects: @"-t" , [nsstring stringwithformat:@"%@", commandtorun], nil]; nslog(@"run command:%@",commandtorun); [task setarguments:arguments]; [task launch];
any help appreciated.
thanks,
the launch path path command, , seem be placing command name after '-t' in arguments. seek this:
nstask *task = [[nstask alloc] init]; [task setlaunchpath: @"/applications/xcode.app/contents/applications/instruments.app/contents/macos/instruments"]; nsarray *arguments = [nsarray arraywithobjects: @"-t", @"/applications/xcode.app/contents/applications/instruments.app/contents/plugins/automationinstrument.xrplugin/contents/resources/automation.tracetemplate" @"-w", @"ipad retina (7.1 simulator)", nil]; [task setarguments:arguments]; [task launch];
i think nstask places quotes around arguments, i'm not sure, may need set escaped-quotes around "ipad…" argument.
objective-c xcode cocoa instruments nstask
Comments
Post a Comment