Since the release of the first beta of macOS Monterey, I've got an issue while listing the content of the Trash.
I've got a sandboxed app with User Selected File entitlement, I select my User Home folder in an Open dialog box, then I try to list the content of the Trash, but it's empty (whereas it's not!). Even with Full Disk Access given, the content is still empty.
if let trashURL = try? FileManager.default.url(for: FileManager.SearchPathDirectory.trashDirectory, in: .userDomainMask, appropriateFor: nil, create: false) {
if let content = try? FileManager.default.contentsOfDirectory(at: trashURL, includingPropertiesForKeys: nil, options: []) {
print(content)
}
}
It was working fine in macOS Big Sur. Getting Full Disk Access was sufficient to list the content of the Trash.
Is there any change?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
With the RC version of macOS 26, an issue persists when you try to create a bookmark with security scope for the root folder "/". This leads to an error "The file couldn’t be opened.". However, you can create bookmark for /Applications, /System, /Users...
This is quite annoying for one of my app because a user can create a cartography of his disk usage, and the access to the root folder "/" is the only way to do so!
Is there a workaround?
PS: reported the issue with ID FB20186406
let openPanel = NSOpenPanel()
openPanel.canChooseDirectories = true
openPanel.canChooseFiles = false
openPanel.beginSheetModal(for: self.view.window!) { (result) in
guard result == .OK, let folderURL = openPanel.url else {
return
}
openPanel.close()
do {
let data = try folderURL.bookmarkData(options: .withSecurityScope, includingResourceValuesForKeys: nil, relativeTo: nil)
print("Bookmark data was created for \(folderURL.path)")
} catch (let error) {
print("Error creating bookmark for \(folderURL.path), with error: \(error.localizedDescription)")
}
}