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?
-
Especially I'm talking about reaching a breakpoint inside the AppDelegates - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url method? – stigi Jan 17 '09 at 22:26
3 Answers
There is a way to debug your application when it is launched from an external URL:
- Set a breakpoint where you want it in
application:handleOpenURL:
orapplication:didFinishLaunchingWithOptions:
- In Xcode, edit the Active Executable's settings. On the Debugging tab, select the "Wait for next launch/push notification" checkbox.
- 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."
- Open your app by invoking a custom URL or sending it a push notification. The debugger will stop at your breakpoint.

- 135,006
- 31
- 278
- 256
-
Thanks, found the answer myself some month ago, but forgot to post it here. Answer, check! – stigi Apr 26 '10 at 10:16
-
This solution works for Xcode 3.x. For Xcode 4.x, see: http://stackoverflow.com/a/6451601/135712 – Vincent Tourraine Aug 28 '13 at 08:05
I'm on Xcode 8.2.1 and the fastest way is to simply go to Product -> Edit Scheme and select “Wait for executable to be launched” like the image below. When debugging started, it will not launch the app but "waiting for "THE APP" to launch..". When an action (click on the push notification), the breakpoint will kick in.

- 2,811
- 1
- 31
- 52
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.

- 3,261
- 22
- 16