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

I haven't had the issue since updating to macOS 15.1 and haven't got any more reports from users either, but I will update you if I do.

If this happens on macOS 15.1 or later, then please file a new bug create and create a new thread or post the bug number back here (if this happens "soon").

One thing to be aware of here is that a system component like this has a very straightforward API surface (give URL-> get Data) with a very complex underlying implementation (multiple daemons, framework layer, sandboxing, file system issues, etc.). That dynamic means that there's a huge variety of possible failure points... of which look exactly the same at the final API layer ("my bookmark doesn't work").

That makes new bugs particular important because you want to make sure the issue gets investigated quickly by highlighting exactly where/how/when the failure is occur ("15.1, SMB volume, on Tuesdays") and by ensuring that the investigation starts from a "clean" slate, not with the team which happened to be responsible for the previous issue.

The new thread is just a miniature version of the same dynamic, as I can't promise I won't miss an update on this thread if it happens a year from now 🙂.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

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