In a real-world app, we might encounter a situation where we design an app that can send a message or satisfy a certain condition, passively start the load, and initialize it based on some parameters that are passed in.
This is because the program is started by another program, so we are not able to compile the run program and set breakpoints debugging directly in Xcode. Fortunately, Xcode provides debugging capabilities that are attached to the process, and can wait for the process to run through the process name before the process starts, and enter the breakpoint debugging when the process is actually loaded. Here's how:
1, in the Xcode to be debugged select Debug->attach to Process->by Process Identifier or Name ...
2. Enter the process name (usually your project name) in the PID or process name of the dialog box that pops up, and click Attach
After the configuration is complete, you can start other processes on the virtual machine (not the process to be debugged), and when the debugging process is started, Xcode will automatically enter the debug state.
How to set breakpoints debugging in an app that's about to start in Xcode