Persistent Security Bookmark Access in Sync Client Desktop App

Hello Fellow Developers,

I'm reaching out for insights or solutions to a challenge we're encountering with our sync client application, particularly related to maintaining user folder access permissions across app sessions and system restarts. In our application, we leverage the openFileDialog to enable users to select a folder for file downloads and synchronization. To ensure smooth access on subsequent app launches, we save a security bookmark of the chosen folder. This is crucial for our app to function without repeatedly asking for user permissions, thereby enhancing the user experience. However, we've hit a snag where the security bookmark expires after a few days or upon a system restart, leading to a less than ideal scenario where users are prompted for reauthorization through a FileDialog. This repetitive process is not the seamless experience we aim to provide. To address permissions and security, we are currently using two entitlements: com.apple.security.files.bookmarks.document-scope com.apple.security.files.bookmarks.app-scope Despite these, we still face the bookmark expiration issue. We're seeking advice on whether there are other entitlements or methods we should consider to maintain persistent access to the selected folder without the security bookmark expiring. Our goal is to reduce or eliminate the need for users to repeatedly grant access, ensuring a seamless and efficient user experience. Has anyone faced a similar challenge or can offer guidance on additional entitlements or strategies to achieve persistent folder access? Any suggestions, alternative approaches, or insights would be greatly appreciated. We're keen on exploring all possible solutions to enhance our application's functionality and user satisfaction. Thank you for your time and assistance. I look forward to any advice or discussions this community can offer.

we've hit a snag where the security bookmark expires after a few days or upon a system restart

Security-scoped bookmarks shouldn’t expire. They should also persist across restarts.

I’m not sure what’s going on here, but I’m pretty sure it’s not a general problem. Lots of other Mac apps use these facilities successfully.

If you create a small test project to exercise this, does it show the same problem? That is:

  1. Create a new project from the macOS > App template.

  2. Add a button that brings up the open panel.

  3. On completion, create a bookmark and save that.

  4. Add another button to load the bookmark, resolve it, start accessing the scope, and read the file.

  5. Run the app and click the first button and the second to make sure this works.

  6. Restart your Mac.

  7. Run the app again and click the second button.

Share and Enjoy

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

Persistent Security Bookmark Access in Sync Client Desktop App
 
 
Q