1
votes

I have tried about every document type and delegate method by now, and my non-document-based app just doesn't accept any dropped file/folder on the dock icon.

This is the document type I copied from Apples Notes app which supports dropping folders on its icon:

<dict>
    <key>CFBundleTypeName</key>
    <string>General files and folders</string>
    <key>CFBundleTypeRole</key>
    <string>Viewer</string>
    <key>LSItemContentTypes</key>
    <array>
        <string>public.folder</string>
    </array>
</dict>

The delegate is set correctly, otherwise my applicationWillFinishLaunching would not be called at all.

I tried to implement any of

  • application(_ sender: NSApplication, openFile filename: String) -> Bool
  • application(_ sender: NSApplication, openFiles filenames: [String])

with no success. I just cannot get the dock icon to accept a drop. What am I missing?

UPDATE:

Turns out I have to drag the Debug build to /Applications in order for a drag to be accepted. This is more than cumbersome, to say the least. Any way around this?

1

1 Answers

2
votes

This seems very strange, but here is what I did to get it working:

  • Drag the Debug build to /Applications
  • Launch it and drag a file to it
  • Build and run the app from Xcode again. Drop is now also accepted for the Xcode build outside of /Applications
  • You can now remove the copied version from /Applications, drop still works.