TL;DR for impatient developers:
Don’t forget to allow the app to access the filesystem.
Okay, we need to make a dialog, so let’s make a variable named dialog and assign it the NSSavePanel.
Then we have to set some parameters. Let’s give the dialog a title-bar name.
The parameter names are pretty self-explanatory, but these options are for showing the “resize” button in the title bar, allowing users to create new folders, and showing hidden files.
If you want to restrict users so that they can only select certain files:
We then expose the dialog to the users:
Great, so we’re done now, right? Not so fast! If you run your app now, it will crash. What gives? Well, you forgot to allow the app access to your filesystem! Simply click on your project on the left sidebar, press on your app under the smaller sidebar with the title-name “Targets”, choose “Capabilities” on the top bar, and then choose Read/Write under “User Selected File”.
You should now have a functional save panel!