For whatever reason SwiftUI sheets don't seem to be resizable anymore.
The exact same code/project produces resizable Sheets in XCode 15.4 but unresizable ones with Swift included in Xcode 16 beta 2.
Tried explicitly providing .fixedSize(horizontal false, vertical: false)
everywhere humanly possible hoping for a fix but sheets are still stuck at an awkward size (turns out be the minWidth
/minHeight
if I provide in .frame
).
Thanks Steve, I appreciate the problem as well. Have you considered this from a framework evolution perspective? In order to evolve the framework and add new APIs, we have to make judgement calls on where we make these changes. One thing to note — this retroactive reinterpretation is link checked. That is, if a person runs your app on Sequoia before you recompile with the new SDK, the sheet will be resizable still for them. w.r.t #available
, you could do something like this:
extension View {
@ViewBuilder
func resizableSheet() -> some View {
if #available(macOS 18.0, *) {
self.presentationSizing(.fitted)
} else {
self
}
}
}
And then remove that 2-4 years down the line. Since the availability check isn't changing at runtime, you won't see identity changing in that conditional. Typically, we decide that making this available but inert in prior releases is more harmful as it could give someone writing this code for the first time deploying to macOS 14 and up the idea that presentationSizing
does something on macOS 14.0.