How to compile code using @Query macro using a toolchain

Hi S/E,

I’m trying to work out why with Xcode 26.1 if I download a swift-6.1.2-RELEASE toolchain some code using the attribute I mention won’t compile using the toolchain. The same happens with Xcode 16.4 and a 6.1.2 toolchain. It seems it doesn’t see the attribute I mentioned at all and I’d wager it’s something to do with macro implementations not loading due to something different about the compiler or this not being supported. Has anybody had this problem or know of a way to make this work?

Cheers

Nevermind, I’ve answered my own question. My Xcodes are on an external drive and I needed to give swift-frontend in the toolchain “Full Disk Access”.

No, that wasn’t it. Still looking for a solution. I can rebuild the compiler if need be.

It's hard to say without any logs or details about the failures that you're seeing, but my guess is this: unlike macros built from Swift packages, which are standalone executables, the macros that come with Apple's system frameworks are dylibs and they're bundled with the toolchain, not with the SDKs. So a toolchain downloaded from swift.org simply won't have the macro libraries that Xcode would be looking for.

Thanks for the response, the error is Unknown attribute 'Query' with no other indication of a problem. This is part of SwiftData right? Yet the swift-frontend invocation seems to be doing the right thing (I’ve moved Xcode + the toolchain onto my main disk and the Macro.dylib seems to exist in Xcode’s toolchain). It just doesn’t seem to work, should be easy enough to replicate.

-load-resolved-plugin /Applications/Xcode164.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/swift/host/plugins/libSwiftDataMacros.dylib\#/Applications/Xcode164.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/swift-plugin-server\#SwiftDataMacros

Edit: I’ve opened a radar FB20947477 with instructions to replicate using this project