Ah, I got it backwards. Looks like you have an older version of the prebuilts cached. We had to republish the macOS prebuilts for the new Xcode version.
The prebuilts are cached in your ~/.swiftpm/cache/prebuilts. To get a clean start, remove that directory as well as the SwiftPM scratch directory (.build) or the DerivedData directory for your project if you're using Xcode.
Excellent. Should be sorted out. I have submitted a change to SwiftPM 6.2 to be more specific what compiler version generated the prebuilts so we can make sure it matches.
Is there a way you could make a sample project exhibiting this and raise an issue in the bug reporter? @dschaefer2 is this something you have seen internally?
Same here: When using "legacy previews execution" (which I need due to this issue - FB16398108), the build fails with swift-syntax prebuilts:
[...]/SourcePackages/checkouts/MyMacro/Sources/MyMacrosPlugin/MyMacro.swift:9:8: Cannot load module 'SwiftSyntax' built with SDK 'macosx15.5' when using SDK 'iphonesimulator18.5': [...]/SourcePackages/prebuilts/swift-syntax/601.0.1/6.1-MacroSupport-macos_aarch64/Modules/SwiftSyntax.swiftmodule
Is there a way you could make a sample project exhibiting this and raise an issue in the bug reporter?
Unfortunately no. It's not even clear to us why we need to use "Legacy Previews Execution" in our project. We have our previews conditionally compiled with #if DEBUG but we are not doing conditional compilation specific to running previews, it's the same build.
Our project is huge, so it would be very difficult to create a sample project that exhibited this behaviour, since we don't know why we need to use "Legacy Previews Execution", which seems to be the cause of this issue, see: [Preview] Swift-Syntax Prebuilts for Macros - #45 by ChristophK above.
BTW, I can reproduce this. But, yes, this is crossing into Xcode. Could you raise a bug in the Feedback system (it'll come to me). Bug Reporting - Apple Developer
We're using Xcode 16.4 and swift-syntax 601.0.1. We added a script that sets defaults write com.apple.dt.Xcode IDEPackageEnablePrebuilts YES on local machines and in CI, and see great performance wins across the board, and as expected, especially in release builds.
Thank you for making this available in a very simple and largely transparent way
This is an amazing improvement, and was much awaited!
I think I found another problem in the interaction of macros, the less known but very useful swift build --explicit-target-dependency-import-check=error option[1], and the new --enable-experimental-prebuilts flag. Here's a very simple reproducer:
Check out tag 6.1.1 (because main uses a version of Swift Syntax which isn't prebuilt yet!)
swift build --explicit-target-dependency-import-check=error --enable-experimental-prebuilts
This attempts to build the library with its macros but produces errors due to the dependency check:
error: Target TestingMacros imports another target (SwiftDiagnostics) in the package without declaring it a dependency.
error: Target TestingMacrosTests imports another target (SwiftSyntaxMacros) in the package without declaring it a dependency.
(In fact, it randomly varies by build which missing dependency it lists above.)
In contrast, if I rm -rf ~/.swiftpm/cache/prebuilts and retry the above without --enable-experimental-prebuilts, then no such errors appear.
(Edit: Removed mention about --build-tests failing. I guess the tests only failed to build because the regular target itself didn't build successfully.)
I keep wondering why it's not on by default, at least warn by default! âŠī¸
Although mentioned in the Xcode 26b1 release notes, there don't appear to be any prebuilt available for that version yet, even with the default enabled. What sort of latency should be expect between beta release and prebuilts going forward?
They are there as of 90 minutes ago. However if you've been playing with the beta before that it's caching that you tried and it wasn't there. It's a bit awkward to clean up but I'm working on a fix for that. For now you need to do the following:
remove the following directory ~/Library/Developer/Xcode/DerivedData/<project name>/SourcePackages/prebuilts. That's the cache for that project.
In Xcode File menu select Packages -> Reset Package Caches, to force reloading of the package and setting up the prebuilts.
Clean Build Folder and Build again
I'll add the clean up of the prebuilts to the reset function in SwiftPM and Xcode.