Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

The Spotlight Import Extension does not allow to inspect document bundles to get the metadata for the spotlight

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?

The Spotlight Import Extension does not allow to inspect document bundles to get the metadata for the spotlight
 
 
Q