Retain NSOpenPanel file permissions after the app is quit in swift

My app lets you create projects which can hold images, and a file watcher watches the folders for changes. By default the images are stored in the application support folder, but I'm adding the ability to choose an external folder to save them too.

The user chooses a folder with an NSOpenPanel, and the project loads the images in the folder. The folder location is then saved to a json file in the app's support folder.

This works great, until the app is quit. When it launches again it can't read the contents of the folder anymore due to app sandbox.

How do you retain the permission to read from a folder even after the app is quit? I've been searching for over a day, but can't find any current information.

Any help would be appreciated!
Answered by DTS Engineer in 659535022

How do you retain the permission to read from a folder even after the
app is quit?

Via a security-scoped bookmark. See Security-Scoped Bookmarks and Persistent Resource Access.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Accepted Answer

How do you retain the permission to read from a folder even after the
app is quit?

Via a security-scoped bookmark. See Security-Scoped Bookmarks and Persistent Resource Access.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Retain NSOpenPanel file permissions after the app is quit in swift
 
 
Q