views:

319

answers:

2

I'm developing an app for the iPhone, but I guess the question is the same on the Mac. What is your approach to debug the state of your application after it has been launched by its URL scheme?

+2  A: 

Actually, I think it would be quite different on the Mac than on the iPhone as you can have the application open already on the Mac and call the URL scheme, whereas on the iPhone you need to quit the application to open another to call the URL scheme.

What you could try is adding a debug button to your UI which allows you to call the URL scheme from inside the running application (calling -openURL: on NSWorkspace). This should in theory work the same whether your app is open or closed when the URL scheme is sent.

Martin Pilkington
thanks, i also think thats the way to go then..
stigi
+1  A: 

There is a way to debug your application when it is launched from an external URL:

  1. Set a breakpoint where you want it in application:handleOpenURL: or application:didFinishLaunchingWithOptions:
  2. In Xcode, edit the Active Executable's settings. On the Debugging tab, select the "Wait for next launch/push notification" checkbox.
  3. Build and Debug. The Console will give you an alert saying "Waiting for [AppName] to launch... The debugger will attach to [AppName] the next time it is launched."
  4. Open your app by invoking a custom URL or sending it a push notification. The debugger will stop at your breakpoint.
Ole Begemann
Thanks, found the answer myself some month ago, but forgot to post it here. Answer, check!
stigi