I'm building a macOS app which programmatically sets Finder tags for files using extended attributes similar to this answer for Swift 3: Set Finder label color. This works well.
However, I'd like to create a tag and make it available in the filesystem without having to add the tag to a particular file. For example, when the user clicks a button, I want to create a tag, similar to Finder - Preferences - Tags, where you can create a new tag by pressing the + button. You don't have to specify a file or folder.
I tried adding a new tag to _kMDItemUserTags of a dummy folder using the setResourceValue API. This creates the tag as expected. However, the dummy folder now shows up in the search for this tag, which is not nice. As soon as I remove the tag from the dummy folder again (and no other file or folder has this tag) the tag is gone from the list of available tags.
So, I wonder how is it possible to create a new tag in Swift and persist it without assigning it to a file?