SwiftUI & macOS: Drag Files Into Dock

Grace Huang
4 min readNov 15, 2023

In this tutorial, we will walk through a macOS example demonstrating how to drag files into an app icon in the dock. This functionality becomes useful when you need to drag content from anywhere on the screen to an area consistently anchored on the screen.

Dragging images into the app icon in the dock

(My latest book “macOS App Development: The SwiftUI Way” is now available. Grab your copy today!)


  • Macbook
  • Xcode
  • Browser

You’ll also need to have a basic understanding of SwiftUI.

Project Setup

Set up a macOS app with SwiftUI, excluding CoreData, and set the Minimum Deployment Target to 12.0.

Set the Min Deployments to be 12, under Target > General

Choose another version based on your target audience. I chose 12.0 because my target audience generally uses lower versions. Considering backward compatibility down the line is crucial for lower versions.

After building the app, you should see the following.



Grace Huang

I write about startups, entrepreneurship, investing, software, hardware and manufacturing.