Swift 6 coming soon?

Is anyone doing development with Swift?

When are we going to have Swift 6?

1 Like
1 Like

Swift needs serious clean‐up, potentially a full rewrite, and solving the mysterious Hydra build issues. There are a couple of people who have expressed interest in doing so for 25.05 in the Nix on macOS Matrix room and I’d like to assist such efforts, which should be easier now that Randy’s macOS SDK rework is in.

The plan would ideally be to update to 5.10, the last version that can be bootstrapped without an existing Swift compiler, and then use that to build Swift 6. If you’re interested in helping out then come say hi on Matrix!

3 Likes

What qualifications would be needed to be helpful in this mission?

Knowing things about the Swift build system would be a big help! Experience with Nix packaging would also of course be necessary, and we’d want to make modifications to the existing LLVM package infrastructure to accommodate Swift’s fork. However we already have lots of people with extensive experience with Nixpkgs and LLVM and relatively few with interest and knowledge of the Swift compiler and its build system and bootstrap process, so that’s the skill that would help the effort most on the margin.

I guess I am not there yet.

Another way one could help is by having a body of Swift code that can be tested with the packaged compiler. If Swift support is going to be reworked, it’s an opportunity to improve things for Swift users.

3 Likes

I did a quick search and it seems there aren’t much swift project available in nixpkgs.

If my pull request got merged then then mas package can be tested on:

I have never worked with nixpkgs before though so I can’t guarantee it.

I’ve started work on cleaning up Swift, so I can update it to Swift 6.1. I am targeting it for 25.11, though I expect it to land sooner rather than later.

9 Likes

Thanks for that PR! It helped me find an issue with my changes. When Swift imports a module, it sometimes needs help with headers because it bypasses the Clang wrapper.

Anyway, this is ab example of mas after the update. fetchSwiftPMDdeps is new. It’s similar to fetchCargoVendor. The hook functionality of swiftpm has been split into a separate hook.

My current status is I have Swift 5.10.1 building, which is needed to bootstrap Swift 6.1. I’m currently doing some testing and working on updating the rest of the packages in swiftPackages.

5 Likes

Status update: I have swiftPackages_5 building with all the tools. Swift provides swift-driver. Nothing is wrapped. I have run into a few complications with Swift 6.1.

  • Swift 6.1 has started using C++ in bridging headers, which goes through its ClangImporter library instead of using the wrapped clang binary.
  • Swift 6.1 requires compiler-rt features that only became available upstream in LLVM 20. While Swift builds its own LLVM, it uses the default compiler-rt.

I spent the last few days working on a patch to Swift to make it read libcxx-cxxflags from the clang wrapper. It works and can build Swift 5.10.1 with C++ interop. I expect Swift 6.1 should also work with the patch, but I need to update the default version of LLVM to LLVM 20 (which was planned for 25.11 anyway).

6 Likes

Is there a possibility of getting swift-sdk in there as well? It looks like that’s necessary for playing around with the new Containerization package that’s part of macOS 26.

The macOS 26 SDK will be added to nixpkgs once macOS 26 is released, and the SDK is publicly available.

My current status is I got blocked building on Linux, had a move in July, and have been out of the country without access to a computer for the last two weeks. After I get back, I want to focus on a number of Darwin things that need to land for 25.11, then I can resume working on Swift 6.

The version of Swift will be whatever the public release is, which is currently 6.1.1 but could be 6.2.

4 Likes

Just to be clear, I’m talking about this, which I don’t think is the same thing as the typical macOS SDKs: Getting Started with the Static Linux SDK | Swift.org

(Not an expert though, just wanted to poke around at it)

Sorry, I misunderstood. I’d forgotten that Apple actually released the source to Containerization.

To answer your question: in the short term, no. My goal for the update is to improve the maintenance situation and start laying the foundation for better Swift support. After that, it should be possible to build on that with better SDK support.

I think there is an opportunity to use Nix to declaratively manage Swift environments and handle cross-compilation, but we can’t even build applications that require Swift 6 right now. That needs fixed first.

1 Like

Swift 6.2 is out, which restores the C++ bootstrap path. That should simplify the update, but it is likely to slip past 25.11 due to my limited availability over the last few months. My focus will still be getting the necessary Darwin updates over the finish line before the freeze.

4 Likes