I've made working Spotlight Import Extension with in macOS 15.5 (24F74). mdimport confirm it's installed, and working. The problem is related to accessing data inside document bundles (package directory)
class ImportExtension: CSImportExtension {
override func update(_ attributes: CSSearchableItemAttributeSet, forFileAt url: URL) throws {
// ERROR: The file "QuickSort.notepad" couldn't be opened because you don't have permission to view it.
let fileWrapper = try FileWrapper(url: url)
}
}
forFileAt
url points to a bundle. In order to read the metadata the extension needs to load the bundle from url
and access its content, however in the sandbox environment,t the url allows only access to the bundle directory itself in particular NSFileWrapper(url: url) fails with error "The file "name.extension" couldn't be opened because you don't have permission to view it.", and effectively prevent from providing useful metadata.
Is there a way to access the Document Bundle content in order to read the metadata for Spotlight?