How do I create a Spotlight Importer target?

How do I create a Spotlight Importer (MDImporter) target for mac OS in Xcode?


There appears to be no such target template available in xcode 9 to 11 (older versions don't run on my machine).

Replies

There appears to be no such target template available in Xcode 9 to 11

Indeed. That should give you some idea as to the general disposition of this technology )-: Most of the focus these days is on Core Spotlight.

Anyway, Spotlight importers are based on

CFPlugin
(yetch!) which, in turn, is just a
CFBundle
. Thus, you can get started with the generic bundle template (macOS > Bundle) and then customise from there.

The required customisation is… well… frankly… ugly. Given that the template is no longer available, the next best thing is to look for a sample. The Spotlight sample is still available in the archive, but you might find better example out there on the ’net.

ps Please drop me a line at the email address in my signature.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

[QUOTE]Indeed. That should give you some idea as to the general disposition of this technology )-: Most of the focus these days is on Core Spotlight.[/QUOTE]


Core Spotlight isn't a direct replacement for Spotlight Importers, is it?


Core Spotlight only works for database-like applications (the exception on macOS). There doesn't seem to be a more modern replacement for custom document files. So everybody who has a custom file format still needs to write a Spotlight Importer.


Thanks to your hint and the Internet I have gotten it to work like this:


The Spotlight Importer template is included in Xcode 8, which is still downloadable. The template is included at


Xcode.app/Contents/Developer/Library/Xcode/Templates/Project\ Templates/Mac/Other/Spotlight\ Importer.xctemplate


The "Spotlight Importer.xctemplate" can be copied to


~/Library/Developer/Xcode/Templates/Spotlight\ Importer.xctemplate


and Xcode 11 will pick it up and happily create Spotlight Importer targets again.


The sample target is Core Data centric and uses some deprecated API - maybe that's why it was removed. After removing the unnecessary Core Data parts it works fine for custom file formats and without deprecation warnings.

Glad to hear that you’re making progress on this.

Core Spotlight isn't a direct replacement for Spotlight Importers, is it?

Correct. To quote WWDC 2017 Session 231 What’s New in Core Spotlight for iOS and macOS (well, the slides, not the transcript), these are “Great for databases, shoeboxes; Not for documents”.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"