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?
So, as more direct confirmation, this is in fact correct:
...CSImportExtension was never fully implemented on macOS.
Multiple bugs have been filed on both the extension point and the documentation, but until something changes in the system, the only option is to use the old MDImport API. You can find more information on that in the "Spotlight Importer Programming Guide" from the documentation archive.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware