When cross compiling for macOS, it's necessary to install the SDK (Software Development Kit) from Apple as well as a suitable compiler. The instructions for Windows (using MSYS2—described in the previous Appendix, Installation Details) and Linux are almost identical; the main work is to install the macOS SDK.
Cross compiling for macOS with CGo
To macOS from Linux or Windows
To prepare for cross compilation to Darwin, we must install the macOS SDK and a build toolchain that can use it. The easiest way to do this is with the osxcross project. This example shows how to download and install the SDK and tools to build for macOS without using a Macintosh computer. This illustration uses Linux but the process...