What is matchingSignature in LibraryItem

From the LibraryItem doc https://developer.apple.com/documentation/developertoolssupport/libraryitem/init(_:visible:title:category:matchingsignature:) there is a matchingSignature which I'm not sure how to use it.

matchingSignature
An overload for which the item presents its code completion. You typically use this parameter when setting up an item as a source of custom code completion. At the time of completion, the code completion engine looks for an item matching the signature and inserts its completion, if found.

What is the valid argument for this parameter?


Replies

I've played with this a little bit and have a few guesses.

My first is that the code was copy-pasta from Snippets, where a matching signature is used for code completion. To look at this yourself put a simple statement somewhere in code, select it, contextual popup menu > create code snippet. Edit the completion (for example, to snozzleberry). Then type snozzleberry in code and it will automatically update itself to the original statement. In such a case, the matching signature is the custom completion.

My second guess is that it should work exactly like snippets do but for modifiers, where base is used for in-place substitutions but it hasn't been finished yet. If so, you can have your matchingSignature be snozzleberry, and if your code is "base.setWidth(2 * base.size)", then it would modify with the two base substitutions.