Current Swift toolchain on macOS Mojave

Is it possible to build current Swift on Mojave? To elaborate:

I quite like the Swift language having written a fair amount of it for iOS apps in the past. Recently I've been using 5.1 on Mojave for some personal non-app tinkering. I'd like to be able to use newer toolchains to get access to 5.3 language features, SPM resource packaging, LSP support, Swift for TensorFlow, Linux ARM cross build, etc. Notably this code doesn't and won't directly use Obj-C interop or any Apple-specific APIs so it seems like this might be possible. My hope is to get a newer Swift toolchain running under Mojave and in the process document the steps.

So far I've attempted to build main and done some spelunking in the resulting errors without much success. The instructions are clear but I'm not familiar with the codebase and apparently veering off the beaten path. My fallback plan is to move work into a Linux VM but that sacrifices OpenGL acceleration.

Any better ideas? Thanks in advance.

Doesn't answer your question, but sidesteps the issue entirely: If you're stuck on Mojave because you have an older Mac, there are third-party patchers that can let you upgrade to newer versions.

The hardware is new enough (2017 13" Pro) but due to some unfortunate regressions in Catalina I'm planning to stay on Mojave for the foreseeable future.

It is unlikely that you'll be able to get a fully functioning Swift toolchain running on Mojave, as the new functionality of newer Swift compilers relies on the new runtimes in the OS and the newer Xcode SDKs to be able to deploy on Mac. If you don't care about any Apple-specific functionality, maybe you could use the Linux toolchain in a VM.

1 Like

There is a neat software Retroactive that allows you to run things "anachronistically" on Mac. One of the things it can do is run Xcode 11.7 on macOS Mojave. Xcode 11.7 has the Swift 5.2.4 toolchain bundled with it. It's not 5.3, but probably as close to it as you can get. However, you still might be limited by Mojave's runtimes, as Joe mentioned.

I never tried this by myself, so I'm not sure if there is any side effect. I've only used it to get iTunes on Catalina.

EDIT: Messed up Swift version numbers in the original reply.

Regarding Linux:

  • I'm using 5.3 on Raspberry Pi OS 64-bit and it works great.
  • I tried some x86_64 Linuxes and the current 5.3 did not compile on one of them, and in the other one it did but my Swift program did not link.

@wowbagger thanks for the tip, Retroactive might help if I do eventually roll forward to Big Sur. It sounds like the best short term path is to move to a Linux VM and if I get really desperate for accelerated GL try to run under Wine.

Terms of Service

Privacy Policy

Cookie Policy