4

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

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

which is invoked via the file drag-and-drop. I want to be able to break and begin debugging inside application:openFile: but must start the app out of Xcode to use drag-and-drop launching.

What would be a good way to do this?

JefferyRPrice
  • 895
  • 5
  • 17

1 Answers1

6

In Xcode go to Product > Edit Scheme (or Option-Click the Run button in the toolbar).
Under the Info tab change the Launch option to

  • Wait for 'EXECUTABLE' to launch

You'll want to set an appropriate breakpoint in your application:openFile: method,
then launch your app manually from the Finder by dropping a document file on the app icon.

To locate the built executable use 'Show in Finder' for your .app in Xcode's Project Navigator (or CMD+1).

The Xcode debugger should attach and break in your method.

Jay
  • 6,572
  • 3
  • 37
  • 65
  • One further thing: you need to go to Product > Run before you manually launch your app from the Finder. Might be obvious to some people, but I missed that step. – Tyson Jul 30 '15 at 20:37