Set the UTI Types the Importer Supports
Our contrived UTI type is specifically for the StickiesDatabase format and designated by an "aaa" extension, which is arbitrarily picked and unlikely to cause any conflicts. In "Info.plist," find the block of code that's commented out (shown below), and remove the comments. Add our UTI type designated by "aaa" and customize the file where applicable. Here's the first relevant code snippet with the interesting lines in bold:
<key>UTExportedTypeDeclarations</key> <array> <dict> <key>UTTypeIdentifier</key> <string>com.apple.stickies.aaa</string> <key>UTTypeReferenceURL</key> <string>http://www.company.com/yourproduct</string> <key>UTTypeDescription</key> <string>The StickiesDatabase Format</string> <key>UTTypeConformsTo</key> <array> <string>public.data</string> <string>public.composite-content</string> </array> <key>UTTypeTagSpecification</key> <dict> <key>com.apple.ostype</key> <string>T78q</string> <key>public.filename-extension</key> <array> <string>aaa</string> </array> </dict> </dict> </array>
At least two other changes need to happen. One of these changes is another UTI-type placeholder:
<key>LSItemContentTypes</key> <array> <string>com.apple.stickies.aaa</string> </array>
The other change is with regard to our bundle identifier:
It's crucial to understand the format of the "Info.plist" file. A single typo in the wrong spot or swapping "com.foo.whatever.aaa" with just "aaa" will cause your plugin to fail, and these types of errors can be difficult to track down.
Update the schema.xml File
While the "Info.plist" file primarily handles information that pertains to a file's UTI, the "schema.xml" file handles the file's actual metadata attributes—including custom ones that are specific to our application. In our case, this flexibility is crucial to getting our importer up and running. Since Stickies can store an arbitrary number of notes in a single file, we'll use a multivalued string attribute, where each value of the string will correspond to the text of a note. Without the availability of multivalued attributes, we'd be stuck placing an upper limit on the number of notes that could be indexed.
Here's an updated "schema.xml" file. The only notable changes are that the reverse DNS suffix placeholders were updated, and we identified our multivalued attribute.
<attributes> <attribute name="com_apple_stickies_aaa_noteTitle" multivalued="true" type="CFString"/> </attributes> <types> <type name="com.apple.stickies.aaa"> <note> The keys that this metadata importer handles. </note> <allattrs> com_apple_stickies_aaa_noteTitle </allattrs> <displayattrs> com_apple_stickies_aaa_noteTitle </displayattrs> </type> </types>
The "schema.strings" file (created automatically as part of a "Spotlight Plugin" project) facilitates localization by mapping attribute names to various languages. This kind of support keeps people all over the globe happy. If you want to support more than one language, this is the place to go.