Cross-Compiling macOS to Linux

It is supposed to be possible for the main development branch, and some people use it that way. But it hasn’t been officially supported in any release and remains undocumented. Nor is it tested very well (if at all), so it tends to end up broken from time to time.

That said, you could look at the original pull request to SwiftPM, which is rather old, but includes examples specifically for the macOS‐to‐Ubuntu scenario. You could also compare my more recent script for cross‐compiling for Android. It targets a different platform, but it serves as a more modern demonstration of what you’ll need and how you’ll need to use it.

But you should know that the it won’t be nearly as easy as using Docker, which also has the benefit of official support and thorough testing. For most developers wanting to compile for Ubuntu from macOS, the Docker method is what I would recommend.

1 Like