Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug when implementing the handleOpenURL message?

I'm writing an iPhone app that can be started via a custom URL. So, I override - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url

To test my changes, I have to run the app in the simulator, then quit out and launch Safari. I then type in my custom URL in the address bar to launch the app.

But every time I launch, the app crashes. I'm trying to figure out why, but when I set a breakpoint and launch the app from the home screen (instead of in XCode) it doesn't seem to attach.

I even tried putting NSLog statements in the handleOpenURL message, but they don't get printed to the console.

I suppose I could create UIAlertViews but... yeah, yikes. Any other way to connect to a debug session in the Simulator?

like image 902
bpapa Avatar asked May 21 '09 17:05

bpapa


1 Answers

In Xcode 4, you can edit your target's scheme and in the "Run" section, "Info" tab, you can choose the "Wait for MyApp.app to launch" option:

enter image description here

This will cause the debugger to wait until the next time your app starts, and then attach to that process rather than creating a new process for you. This will let you launch your app manually from Safari and use the debugger.

like image 137
Mike Weller Avatar answered Oct 13 '22 10:10

Mike Weller