Unavailability on macOS

I find it incredulous that Swift can be installed, up to the latest version on Linux but not macOS. Also, the lack of sample programs for macOS is alarming. It is a definite hit against Swift's future as a useful tool on Macintosh. To tie the elements of a version to the development environment (Xcode) is something I have not seen in 40 years of programming. Surely if we are to be denied access to an "open source" language in the development environment, we should be able install the compiler, linker, runtime, core libraries and basically everything on this site via Macport, Brew or at the minimum as a Makefile project to be installed in /opt/local... so that we can learn the latest version without buying a new computer. Why is this not the case?

1 Like

I have used toolchains built from master on my MacBook. What trouble have you had which leads you to believe this is not possible?

On the download page an xcode version is given as requirement for each swift version. And the Xcode versions themself have a minimum mac os version as requirement.

You are misunderstanding that part of the page. It's telling you which version of Xcode came with each Swift version. It is not telling you that you need that version of Xcode before you can run that version of the toolchain. In addition, the App Store requires using Xcode-provided toolchains. App distributed via other means can use any version they like.

I think he's talking about platform support in general. Even just limited to Ubuntu, Linux's OS support is much wider than macOS', which is rather ironic. Also, the toolchains aren't generally usable outside Xcode, are they? Being able to do brew install swift would be much nicer for anyone who doesn't want or can't run the version of Xcode required for the toolchains.


I don't really follow. You can use the toolchains without Xcode. If someone wants to build and maintain a brew cask for it, there's nothing stopping them. It's not really surprising that Apple pushes Xcode, given that any Mac can run it, and it's the official IDE for the platform. But there's really nothing stopping a person from using Swift without it.

1 Like

Technically true, but how would anyone not intimately familiar with how the toolchains work figure that out? You don't get access to their tools after install like you might think, you'd have to use the full paths, no?

And that still doesn't solve the version requirement issue, unless the toolchains have lower requirements than the Xcode's they're intended to be used with. Is that the case?

1 Like

Granted it’s not official, and hence not mentioned on swift.org. But a quick way to get Swift installed without knowing anything about Xcode would be to install swiftenv with Homebrew and then do:

swiftenv install 5.1.2

Edit: 5.1.3 is in a sort of half‐released state, and thus might not work with swiftenv yet.

Does that swiftenv trick install a toolchain that Xcode can use, or would I have to switch to VS Code for that?

I haven’t tried it. Its documentation says the following, so my guess is the reverse is true as well. :crossed_fingers:

NOTE : swiftenv will automatically pick up any versions of Swift installed on macOS by Xcode or Swift toolchains.

1 Like

I think it's the other way around. The default version of the Xcode toolchain is tied to a specific version of Swift. However, you can build and install all Swift toolchains, and, in fact, you can build toolchains that include swift and clang so that you can use them as alternative toolchains with Xcode.

Someone familiar with swift has to build a brew cask recipe, or a Macports installer, or a Fink installer, etc., just like someone had to sit down and build a brew cask recipe for gcc, etc.. No one has chosen do to so thus far. You are welcome to do that if you so choose.

1 Like

Thank you for taking the time to think this through, Jon. For the rest, the folks that believe that the “open source” Swift can be installed and used on macOS, please be so kind as to demonstrate how.
The only way that I see that might work is to take and try and modify the Linux build methods. This probably leaves me without any graphical approach to constructing applications with macOS GUIs but at least I might be able to use a command line application or manually construct the user interface all in code.
I have built ports of several sophisticated applications such as swi-prolog and anaconda so I can’t imagine why Apple would deny the latest versions of Swift from people running “ancient” OSs like High Sierra due to hardware limitations. The only real significant difference seems to be in Hypervisor support in the earlier Xeon class processors and I very much doubt that, like running Mojave on Early 2009 Mac Pros, there is not a trivial set of patches that Apple could supply to not force obsolescence of 8 core, dual processor systems costing in the thousands in 2009.
Anyone looked at the pricing of the current Mac Pro? “The machine for the 1% of us.” I simply cannot afford to replace my machine on Social Security Disability pay.
There is always the free virtual machine environment from Oracle where I can possibly install the Linux versions of Swift 5+ or when Apple denies access to the App Store or other essential services I can just clean out a decade or more of work and install Linux. A real shame.

The Linux build methods you refer to are the only build methods there are (that I am aware of). They are developed and tested on macOS as well as Linux (these are what the Apple developers use, if I'm not mistaken). They work on macOS and Linux, at least (they may even work on Windows, @compnerd has the specifics). I have built Swift toolchains on my MacBook Pro using the the command line tools.

You can use alternative toolchains with Xcode, but you will need compatible version of clang for Objective-C, etc..

If I understand you correctly, if you want to build macOS GUI applications, then you are constrained by the versions of AppKit, et al, and the system libraries, that are compatible with the Swift version you want to use. If you are using a system that supports Swift 5.0 and beyond, you may not have too many worries since the Swift libraries are ABI-stable starting with Swift 5.0.

1 Like

I just tried downloading Swift 5.1.2 Toolchain. I can install it on MacOS10.12.6/Xcode9.2 But can not run it.

swiftc test.swift -o test
:0: error: Swift does not support the SDK 'MacOSX10.13.sdk'

Are you saying that is supposed to work?

1 Like

I’m stuck with Xcode 10.1, Swift v 4.2 as I am running High Sierra, the latest OS that doesn’t require a Metal compatible graphics card and yet another firmware patch. I can’t even do that easily as I was foolish enough to add a boot restricting passcode who’s password screen will not allow me to move my mouse or type anything via the keyboard. Apple support refused to help, telling me my $3000 Early 2009 Mac Pro is officially “obsolete”.
I understand from the Mac underground that a bizarre means of removing the lock can be performed by removing a stick of RAM, some more voodoo and reinstalling the RAM. I am disabled so juggling a full Mac Pro is beyond my abilities.

I don’t understand your complaint. Installation is easier on macOS than it is on Linux. Just download whichever toolchain you want and follow the provided instructions, skipping steps 3 and 4 if you don’t care about being able to use it with Xcode. Step 5 lists two options; use the second one that doesn’t go through Xcode.

No. Swift has system requirements just like any other program. You will not be able to run every version of Swift on every version of macOS.

With macOS 10.12, you are probably restricted to Swift 3.x—or maybe Swift 4.x if you managed to get Xcode 9 installed, which is supposed to be impossible according the chart I was looking at. :man_shrugging:

1 Like

Well in my opinion it's not abvious how a language/compiler requires a specific OS version. For example rust, nodejs, c, c++, php, haskell, python, clojure, java, racket do not have this issue.
Given that swift runs on linux as well I can not be a dependency on a specific API that was only recently introduced in mac os.


Can you install Xcode 10.3? Are are you prohibited from installing anything from the AppStore or developer.apple.com?

Linux does not have to deal with Objective-C interoperability, which is version-dependent on the Mac. If you are building on a Mac, that is a constraint.

@jonprescott funny that you mention me with regards to difficult to setting up a toolchain to run on Linux or Windows. My recent post was directed directly towards that issue. There are docker images that I have setup that have a pre-configured toolchain + Linux (Swift) SDK + Android (Swift) SDK + Windows (Swift) SDK + VSCode. There are still some rough edges to smooth out there (related to the patches that I am waiting on from @Devin_Coughlin and @brentdax), but, it should be possible to use that to build for Linux currently. They are available at http://hub.docker.com/r/compnerd/swift and the rules for that are in my GitHub repository with the remainder of the build configuration. I'd welcome help to improve that experience, but it should largely have most of the pieces there.

Terms of Service

Privacy Policy

Cookie Policy