macOS SwiftUI Sheets are no longer resizable (Xcode 16 beta2)

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).

Answered by Frameworks Engineer in 793625022

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.

Accepted Answer

This is new functionality in Sequoia. The new presentationSizing API in iOS 18, macOS 15 and aligned releases makes sheet sizing more consistent across platforms.

If you want a resizable sheet, use the .fitted sizing:

.sheet(...) {
  MySheetContent()
    .presentationSizing(.fitted)
    .frame(
      minWidth: 100, minHeight, maxWidth: 600, 
      minHeight: 200, maxHeight: 600)
}

.fitted is opt-in to encourage setting a frame with specific min/idea/max dimensions. This prevents certain unexpected layouts. For example, in a multi-platform app, a sheet containing mostly text content on iOS may render unexpectedly on the mac if fitted sizing were the default.

See the Sequoia Release Notes (search 117551515) for more on this. And the presentationSizing docs

I see, thank you for pointing to this! :)

Minor note: I always have a somewhat mixed feeling when a change retroactively reinterprets existing code like this (also: no warning given by Xcode about any possible ambiguity or change in interpretation), especially when a modifier that is required to restore existing behavior is available only in the latest version of the OS and therefore will make us live with a lot of #if available() blocks for years to came. It would be great at least to have the #available attribute for single modifiers - now one either needs to create a custom modifier to deal with this issue or put large chunks of SwiftUI codes into if #available() blocks because of a single version specific modifier.

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.

Right, that makes sense. Thanks for the insight and the code, much appreciated! :)

macOS SwiftUI Sheets are no longer resizable (Xcode 16 beta2)
 
 
Q