[macOS] CoreSpotlight importer using CSImportExtension failing to index

I've been trying to add a CoreSpotlight indexer to my macOS application. The new template for the indexer uses the new appex CSImportExtension style importer.

I've been following this ->

https://developer.apple.com/documentation/corespotlight/csimportextension

  1. I changed the CSSupportedContentTypes in the Info.plist file to the correct file type uti.
  2. I added a dummy value into the attributes (see code below) - just setting contentDescription to 'noodle' (easy to search for)
class ImportExtension: CSImportExtension {
   override func update(_ attributes: CSSearchableItemAttributeSet, forFileAt: URL) throws {
      // Add a dummy value, and see whether spotlight finds it
      attributes.contentDescription = "noodle"
   }
}
  1. I have a number of files on disk that match the uti (and can be found when I search by the file name)

Yet, when I build and run my app, the a spotlight search for 'noodle' finds no results.

Can anyone give me any advice? I cannot find any indication that the ImportExtension is called (although when I put a log message at the start of the update() call there's no message in the console which seems to suggest it's not being called).

Is there any way of debugging this?

Cheers and thanks -- Darren.

Btw I've tried this using Xcode 12, Xcode 13 beta, macOS 12 and macOS 13 beta. No luck with any combo

I cannot find any indication that the ImportExtension is called

That’s my experience. I researched this in gory detail as part of a DTS TSI and my conclusion was that Core Spotlight importer extensions just don’t work on the Mac )-:

While we have a bug on file about this (r. 91288903), I would appreciate you filing your own bug based on your recent experience.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for the update mate. I have filed FB11490572 as you've mentioned.

Frustrating, but lets hope it can get some eyeballs on it.

In case it helps anyone, with some effort I was able to write a MDImporter plugin in Swift: https://github.com/foxglove/MCAPSpotlightImporter

It would’ve been much nicer to write it as a CSImportExtension, and it does seem that mdimport on macOS has some references to “modern importers” (see mdimport -help), but as mentioned above, I wasn’t able to get CSImportExtensions to work at all on macOS. I saw some logs related to them so it seems like it is partially implemented, but somehow broken.

The Swift MDImporter will work as a stand-in for now, but I look forward to replacing it someday!

Just wanted to update this thread with current information. I'm currently building a CSImportExtension and got it to run on macOS 15.0. So at some point this was fixed.

At first I could not get it to run, but then I noticed that when running the mdimport debug commands, the type identifier is all lowercase, even though the identifier we defined in our application has some uppercase letters. So while our document identifier is actually "com.company.someFile", in the Info.plist of the CSImportExtension we had to define it as "com.company.somefile" for it to be run.

Also be aware: While the mdimport -d3 command for testing will say something like: Imported 'foo/bar/xxxx.ext' of type 'com.company.somefile' with no plugIn, the plugin is being called just fine.

[macOS] CoreSpotlight importer using CSImportExtension failing to index
 
 
Q