Weak let, features deployed in Swift patch releases, #if compiler, etc

It looks like the syntax for weak let was enabled sometime between Xcode 26.0 and 26.2. (That is, it's not in Swift 6.2, it is in Swift 6.2.3).

Along with the syntax, comes a warning for a weak var that's not written to. I'd like to avoid this warning when building with Xcode 26.2/Swift 6.2.3, whilst also allowing my code to be built by Xcode 26.0/6.2.

I expected that #if compiler(>=6.2.3) would allow me to achieve this, but it seems like patch versions don't work in this directive (>=6.2 is active, >=6.2.1 etc. are not).

Do I have any options?

1 Like

in the OSS distributions the compiler condition with patch version numbers seemed like it worked correctly... could it just be an Xcode UI issue? FWIW there also appears to be a bug involving the directives themselves that seems like it will just suppress the 'never mutated' warning altogether.

1 Like

You're right, it does seem to work correctly in the actual compiler, even though Xcode shows the wrong thing. I presumed Xcode's highlighting was coming from SourceKit, but I guess not :(