It would be nice to update the Android.md on swift documentation to reflect the fact that building from linux isn't compulsory and provide steps on how to build for android from a mac.
I don't use macOS, so can't be me (I may be the only person using Swift who's never used it on an Apple platform, as I own no Apple hardware, not even an iPhone).
the work you've linked from @KittyMac seems to be about using a docker container based on an ubuntu distribution to actually build swift code targetting android.
Yes, many people find using such prebuilt Docker containers the easiest way to use a new toolchain, and of course Docker works fine on macOS, though he reports his work doesn't run on Apple Silicon, so you need macOS x86_64.
Does this mean one can't compile swift code to target android directly from a macos, without any kind of linux installation ?
Of course not, @v.gorlov maintained a mac->droid toolchain for several years, before recently discontinuing it.
in golang, one only needs to set a couple of environment variables (cpu architecture, operating system) before calling "go build" (on any platform), and the resulting library / executable will be directly working on the target system. Without having to install any kind of docker container, or VM or anything
golang's corporate sponsor, google, is highly multi-platform and the language is more aimed at such cross-platform use, unlike Swift's corporate sponsor. That said, what you want is available in these community-provided projects, though it requires more configuration.
Are there any equivalent in swift for targeting the android platform ?
I recently saw this company that is working on something like that, another one posted in the forum before. As my first Docker link shows, bridging Swift and Kotlin/JVM requires some work, so only these companies go to that extent: no OSS project does all that for free.