views:

278

answers:

2

I'm debugging a Cocoa application that can act as a handler to a custom URL protocol. The application works fine when I click on a link after the application has launched, but something is causing the app to crash if it has not launched at the time the link is clicked.

Is there any way that I can start the app in the debugger and "fool" it into thinking that I had just clicked on a link?

A: 

Could you attach to your process from XCode once the URL handler has been invoked? You could try putting a modal NSAlert in your URL handler code so that will pause it until you can attach to your process.

Andy
I tried that, but it somehow changes the order in which startup continues, making it impossible to reproduce the exact scenario that I was experiencing.
David Mitchell
+4  A: 

You can do

gdb --wait myAppName

and then click on the link to launch your app. This will cause your app to break into the debugger very, very early, before main has started.

Ken