Debug NSDocument application at startup by dragging and dropping files?

Suppose I have an NSDocument application that supports dragging and dropping a file onto its icon to launch the application and open that file. My NSApplicationDelegate implemented

- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename 

which is called by dragging and dropping a file. I want to be able to interrupt and start debugging inside application:openFile: but I have to start the application from Xcode to start the drag and drop.

What would be a good way to do this?

+4
source share
1 answer

In Xcode, go to Product> Change Schema (or select an option - click the Run button on the toolbar).
On the Info tab, change the launch option to

  • Wait for EXECUTABLE to start.

You need to set the appropriate breakpoint in your application:openFile: method
then launch the application manually from Finder, dropping the document file on the application icon.

To find the Show in Finder embedded executable for your .app in the Xcode Project Navigator (or CMD + 1).

The Xcode debugger should hook and break in your method.

+5
source

All Articles