Creating file bookmarks doesn't work anymore on macOS 15 Sequoia

Before updating to macOS 15 Sequoia, I used to be able to create file bookmarks with this code:

let openPanel = NSOpenPanel()
openPanel.runModal()
let url = openPanel.urls[0]
do {
    let _ = try url.bookmarkData(options: [.withSecurityScope])
} catch {
    print(error)
}

Now I get an error

Error Domain=NSCocoaErrorDomain Code=256 "Failed to retrieve app-scope key"

These are the entitlements:

com.apple.security.app-sandbox
com.apple.security.files.user-selected.read-write
com.apple.security.files.bookmarks.app-scope

Strangely, my own apps continued working, after updating to macOS 15 some days ago, until a few moments ago. Then it seems that all of a sudden my existing bookmarks couldn't be resolved anymore, and no new bookmarks could be created. What could be the problem?

Answered by DTS Engineer in 806097022

Yesterday I filed FB15258541.

Thank you, that was very helpful.

What you're hitting is bug in "ScopedBookmarksAgent" which can cause it hang if it happens to have been launched when the keychain was also locked (for example, late in the screen lock process). That bug is fixed as of macOS 15.1 beta 4.

If you're hitting it regularly during development, you can resolve the issue by killing ScopedBookmarksAgent (you may also need to kill and relaunch your app, depending on what state it ends up). On the user side, a log out (or reboot) should resolve the issue.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

That is great! How about macOS Sequoia, which version is it fixed in there?

Great to see more updates on this bug! Still seeing it for Sequoia users as well so hopefully that's fixed there as well in the 15.3 release?

That is great! How about macOS Sequoia, which version is it fixed in there?

macOS Sequoia had fully resolved the issue as of macOS 15.2.

Great to see more updates on this bug! Still seeing it for Sequoia users as well so hopefully that's fixed there as well in the 15.3 release?

So, we need to be clear about what "it" actually is. Earlier in this thread you said:

I just had this issue again on my own Mac with macOS 15.2. My app had been active for a while and had been able to resolve bookmarks. Then suddenly when trying to create new bookmarks I got the usual error. Restarting the app solved the issue.

This is NOT the bug (r.140342863) this thread has been focused on. The key data point is here:

Restarting the app solved the issue.

The bug (r.140342863) simply cannot be recovered from like this.

Stating this clearly to try and clear up the confusion here, there was a specific security fix that created this bug (r.140342863) in macOS 15 and that fix was then back ported to macOS 13 and 14. The bug effectively broke all security scoped resolution. It should now be fully resolved in:

macOS Sequoia 15.2 (24C101)
macOS Sonoma  14.7.3 (23H417)
macOS Ventura 13.7.3 (22H417)

As a completely separate issue, there a variety of other ways security scoped bookmarks can fail. Notably, the pattern where:

  • They work fine in an app for an extended period of time.

  • They suddenly stop working.

  • They work fine again once the app quits and relaunches.

...is a common and long standing app bug, typically caused by the app slowly leaking security scope references inside the kernel. If you're experiencing that issue, then that's a question you should raise on a new forum thread. It is NOT the issue that this thread is about.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Creating file bookmarks doesn't work anymore on macOS 15 Sequoia
 
 
Q