[Preview] Swift-Syntax Prebuilts for Macros

Hey, thank you for helping the whole community, this is a huge improvement and years of waiting saved :smiling_face_with_three_hearts:

I wanted to share that I've discovered an issue with tests, while building my first macros with swift-macro-testing library.

Was having the following issue:

  1. I created sample project (new package -> macros)
  2. Run pre-created sample tests - all working
  3. Switched to swift-macro-testing - tests are not compiling due to Missing required module 'SwiftCompilerPlugin'

Guys from pointfree helped me to understand that this is related to IDEPackageEnablePrebuilts, and after switching it to NO I was able to compile and run tests.

I had this issue with xcode 16.4 as well as xcode 26. And reported it to Apple as FB19179615.

Here is the code GitHub - andreichenchik/ViewInspectorHelper it's nothing much there, micro macros :wink:

Let me know if I can help in any way

1 Like

Great news, thanks for your effort!

I gave tried it out with Xcode 26 beta 4 and SwiftSyntax "601.0.1", just copying stringify macro example.

The build time changed from 6 to 20 seconds with defaults write com.apple.dt.Xcode IDEPackageEnablePrebuilts YES

Without IDEPackageEnablePrebuilts YES flag build time is 23 seconds.

No matter why the build time differs when IDEPackageEnablePrebuilts is set to yes or no, the overall build time increment is small enough for adopting macro in library development.

Sounds like you didn’t get the prebuilt. The build would be much faster otherwise. And the build impact is much much higher in release builds, especially on slower builder VMs.

You are right, I've recently seen build graph and SwiftSyntax is compiled.

I've sent a response.

There is an issue with macros depending on libraries that also depend on swift-syntax. Since we can't immediately tell whether the library is also a dependency for non macro targets, or ones that build for non-host platforms, we fall back to building from source.

It's probably worth raising an Issue for this on SwiftPM to see whether we have enough information in the package graph to determine that. We just need to make sure we don't break anything.

This is great, thank you for this work @dschaefer2 ! What the first supported version that has the prebuilt behavior? I was unsure if your first message listed those versions as the initial test and if all went well binaries would be provided for older versions as well.

I’m just trying to figure out if I’ll need to update our versions to see this behavior or if all versions of swift-syntax in Xcode 16.4 should automatically see this.

If Xcode 26 betas aren't using prebuilt swift-syntax for our builds, is there any way we can debug why they aren't?

1 Like

Generally, if prebuilts aren’t being used it’s because they haven’t been published for the given toolchain builds. It’s still a manual process to build them for the Xcode beta’s and I don’t think that’s been done for the last couple.

That said, we really should provide a debug message to explain why. Please raise an issue on the swift-package-manager GitHub repo and we can add it to the queue.

1 Like

On a related note, would it be possible to publish a metamanifest.json file that lists all the currently available prebuilt versions? I'd like to look at writing a tool that can download and install the prebuilt outside of Xcode, just to ensure the cache is preheated locally or in CI.

We’re having enough trouble with the current per compiler manifest since the three host platforms build at different times and we need to do a complicated merge which recently just had a bug. I’m actually thinking of changing it so that each prebuilt zip file has its own manifest.

That said, you can assume each released compiler has prebuilts. You can check the generator implementation in SwiftPM’s Source/swift-build-prebuilts/BuildPrebuilts.swift for the naming scheme. That may also change over time, though. For example, I may want to base the Linux ones more closely to the info in the /etc/os-release files on the host.

Sorry to keep bothering you with this, but it seems that while the 6.2.0.19.9 manifest is available, the actual zip is not. https://download.swift.org/prebuilts/swift-syntax/601.0.1/6.2.0.19.9-MacroSupport-macos_aarch64.zip returns 404.

Did anyone else start running into this today? This was working fine for weeks, and suddenly we get:

cannot load module 'SwiftSyntax' built with SDK 'macosx15.2' when using SDK 'macosx15.5': /tmp/build/SourcePackages/prebuilts/swift-syntax/600.0.1/6.1-MacroSupport-macos_aarch64/Modules/SwiftSyntax.swiftmodule

1 Like

Yes I started seeing this just today too. I don’t yet know how to recover from it though. Any advice here is much appreciated!

cannot load module 'SwiftSyntax' built with SDK 'macosx15.2' when using SDK 'macosx15.5': /tmp/build/SourcePackages/prebuilts/swift-syntax/600.0.1/6.1-MacroSupport-macos_aarch64/Modules/SwiftSyntax.swiftmodule

Looks like we’re running into an issue with the minor version update for 6.1.3. Good news, it is fixed in 6.2. But for now, if you run into this, please turn off the experimental flag. Instructions are in the original post on this thread.

This may also be a configuration problem on our end. But for now, if you do see this, you can at least temporarily disable the flag until we conclude our investigation.

Thank you @dschaefer2

We’ve turned it off for now, but we’d appreciate an update. Having it off dramatically slows down our builds.

1 Like

Unfortunately, we’ve had to pull them. There is a bug in the 6.1 SwiftPM that is exposed in the 6.1.3 prebuilts which essentially locked us into to supporting only one version in 6.1, which was 6.1.2.

In 6.2, we now use the compiler version from ‘swiftc -print-target-info’ to make sure we use the prebuilt swift modules appropriate for that compiler version.

Thanks everyone for your help on the 6.1.2 experimental release of this feature. The feedback was invaluable. As you may have seen, that has allowed us to turn it on by default in 6.2 in the beta and snapshot releases.

3 Likes

Any idea when the 6.2 prebuilts will be available? The zip I linked above is still 404ing, despite what the manifest says.

(Also, if you could generate the manifests with constant key order, we'd better be able to check for changes.)

This worked for me just now with SwiftPM:

Downloaded https://download.swift.org/prebuilts/swift-syntax/600.0.1/swiftlang-6.2.0.19.9-MacroSupport-macos_aarch64.zip (0.37s)

That's for version 600 of swift-syntax, 601 is the latest, and what I was trying before. I expect it at https://download.swift.org/prebuilts/swift-syntax/601.0.1/6.2.0.19.9-MacroSupport-macos_aarch64.zip