Guig
Guig

Reputation: 10187

How to tell Xcode to attach debugger to a process as soon as the process will start?

I'm working on something that happens just when my app restarts, and I'm trying to get logs for that. So I build my app, kill it, and restart it.

Killing the app makes Xcode disconnect from the running process.

After I restart the app, I can select Debug > Attach to Process to attach Xcode to the new process, but I'll miss everything that happens between the app start and when I manually attach to the process.

Is there a way to tell Xcode there no process running currently, but as soon as process X starts, attach the debugger to it?

Upvotes: 16

Views: 4555

Answers (1)

Wilmar
Wilmar

Reputation: 1471

Use the Attach to process by PID or Name feature.

It's under the Debug -> Attach to process by PID or Name menu in Xcode, then simply type in the process name that you normally attach to, and select Attach.

Once your app with said PID or name starts up, the debugger will attach to it immediately.

Make sure to set breakpoints for as early as late as you want to catch the launch.

Upvotes: 5

Related Questions