I've been working on a macOS SwiftUI project for a few weeks. Up until today it was going smoothly, using various Xcode 16 betas, but today it stopped compiling. I think this may be the first time I tried to build it with the Xcode 16.0 release version.
The code in question, that I have in three different places in my app, looks like this:
.toolbar { // Trailing closure passed to parameter of type 'Visibility' that does not accept a closure
ToolbarItem {
Button(action: self.addItem) {
Label("Add Item", systemImage: "plus")
}
}
The other instances are similar in nature, with slight variations, but all fail in the same way, and all are fixed in the same way. If I replace Label
with Image
instead, everything builds without error.
However, if I put this same code into a new macOS application project, I can use Label
without issue. The only thing I can think is that the new project has different default settings than the old one (which I created not that long ago, possibly even with an Xcode 16 beta). I don't even know what settings to look for, but maybe it's around the new concurrency? Maybe in Xcode 16 the declaration of Label
changed and it works fine with the new project’s concurrency settings but not the old? Build settings matching "concurrency" are identical between the projects. So is language version (Swift 5).
This is once again an issue where Swift utterly fails to show the actual error occurring.