I am testing the if #avilable feature on swift by writing a command-line tool.
I found 2 interesting minor issues.
It seems that the "macOS Deployment Target" setting does not work in a command-line tool project. Even though I set 12.0 as the deployment target, It stills could run in the 11.0 system.
If so, that’s a known limitation of macOS. High-level APIs, like those used by the Finder, will detect, and refuse to launch an app with a deployment target higher than the current system. Low-level APIs, those used by the shell, do not.
We have a bug on file about this (r. 19339406) but fixing it is a challenge because of compatibility concerns.
In the meantime, if this is a big deal for you then add your own OS version check to the start of main (well, the Swift equivalent).