SwiftUI & macOS: Drag Files Into Dock
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.
(My latest book “macOS App Development: The SwiftUI Way” is now available. Grab your copy today!)
Prerequisites
- 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.
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.