Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terminal command-line debug of iOS Simulator apps?

Is it possible to use GDB or LLDB from the Terminal command-line under Mac OS X to debug apps running on the iOS Simulator? (e.g. not from within Xcode's GUI or console, but using an external command-line or process). If so, how?

like image 897
hotpaw2 Avatar asked Apr 11 '12 18:04

hotpaw2


People also ask

How do I debug iPhone simulator?

You'll need to go to Settings > Advanced and check the Show Debug Menu option. Then you'll see the option to open the web inspector for the Simulator right from that menu. With the Web Inspector open, you can debug inside the Simulator just like you could right in a desktop browser with DevTools.

Which command is used to run the app on iOS simulator?

If you wish to run your app on an iPhone SE (2nd generation), run npx react-native run-ios --simulator='iPhone SE (2nd generation)' . The device names correspond to the list of devices available in Xcode. You can check your available devices by running xcrun simctl list devices from the console.

How can I launch the iOS simulator from terminal?

Just type this command in Terminal: open -a Simulator. app to launch the most recent simulator. Type this command in Terminal to run the Simulator rigth from the its folder.

How do you debug a simulator?

To simulate a background fetch, launch your app in Simulator and then go to Xcode and choose Debug > Simulate Background Fetch.


1 Answers

You'll need to have the app already in the simulator's Springboard; you can't launch the app in the simulator from Xcode and then expect to be able to have a command line instance of gdb attach to it.

So:

  1. Run the iOS Simulator, having already gotten your app into it.
  2. In a terminal window:
    % gdb
    ...
    (gdb) attach --waitfor 'Name Of Your App'
  1. Launch your app from the simulator Springboard.
  2. gdb should attach to the process before main() is executed. So you can set some breakpoints, or whatever. Then:
    (gdb) continue

The procedure for lldb is similar:

    % lldb
    (lldb) process attach -n 'Name Of Your App' --waitfor
    <launch your app in the simulator>
    (lldb) continue

I am not sure why you'd want or need to do this, but as an old command line gdb (and dbx) guy, I can appreciate it. :-)

like image 146
Mark Granoff Avatar answered Sep 18 '22 13:09

Mark Granoff