The documentation page you refer also points to these additional resources (besides the macOSLib project, whose code you may want to inspect in order to learn more about how declares work):
Do the Declare method names have to be the same as the Selector string? If so, why? If not, it would make things clearer if names like “mySub” were used in the examples to make it clear what the we can choose to suit sourselves and what is fixed.
AFAIK “Selector” is only required for “Objective” API, regular flat API doesn’t need it.
The names do not have to match.
declare sub NSObject_release lib Foundation.kLibrary selector "release" ( NSObjectInstance as integer ) // --- This is Objective API.
declare sub CGImageRelease lib CoreGraphics.kLibrary ( CGImagePtr as ptr ) // --- This is flat API.
I left out some parts as to why my declares look different from others.
I personally use className_message for Objective API as this means when I need to look up that API, I get the correct one and when using it in code, it calls the correct API.
I use classNameInstance or classNameClass for property names as this helps remind me what the parameter types need to be. The idea is to spend a little more time when writing the declare, will save time when you need to re-use it 1, 2, 5 or even 10 years later.
Finally I try to either comment in-line declares or add to the “Description” of external method, the minimum OS version that the API works on.
I also prefer NOT to hardcode library names as there have been times when Apple has changed the name of framework you link against, so during a “transition” period, I might make a whole block of declares link against “Cocoa” until my apps minimum version means there’s only one framework I need to worry about, hence why I use constants.
While there are those on this very forum who just think I’m being <insertWordHere/>, these have all come from the experience of working with Xojo declares and Apple’s API for 15 or so years.