0

I'am developing an mac app.I need to open the terminal and execute lldb command. I've found the solution:Open a terminal window to a specified folder from a Cocoa app. However,i need to pass more arguments to the opened terminal after entering lldb mode. so i'm confused about there is any way that my app can communication with the terminal?

for example:

Firstly, i open a terminal and enter in lldb mode.

NSAppleScript *as = [[NSAppleScript alloc] initWithSource: @"tell application \"Terminal\" to do script \"lldb\""];
NSDictionary *errors = nil;
[as executeAndReturnError:&errors];
if (errors) {
    NSLog(@"start lldb error: %@", errors);
}

Then i want to pass lldb command to the opened terminal, like process connect connect://xxxx. But i can't find any way to make it.

  • Not sure why you have tagged [ios], but for macOS [one of these answers](https://stackoverflow.com/questions/26971240/how-do-i-run-a-terminal-command-in-a-swift-script-e-g-xcodebuild) will probably help. – Paulw11 Mar 02 '21 at 09:26
  • because i need use lldb to connect remote ios device. i want to pass some `lldb` command to the terminal, like `process connect connect://xxx`. – user6877720 Mar 02 '21 at 09:48
  • Are you actually using the fact that lldb is running in a Terminal session? If not, it would probably be easier to use NSTask and write & read to the input & output handles that affords. – Jim Ingham Mar 02 '21 at 19:05
  • yep, my thoughts is pass some lldb command from my app. Then execute lldb command in the terminal. But, i can't find any to to communicate between my app and the terminal. By the way, NSTask can perform lldb command? Are there any relative examples? – user6877720 Mar 03 '21 at 02:44

0 Answers0