I've just experienced something similar to this with Xcode Version 26.0 (17A321) I don't have any other versions of Xcode I can try this with.
Supplying .presentationDetents()
with any value, e.g. .presentationDetents([.height(250)])
or .presentationDetents([.medium, .large])
, does the following:
- iOS 17.5 Simulator: The sheet is not displayed at all, effectively freezing the app as there's no sheet displayed and no way to dismiss it.
- iOS 18.5 Simulator: The sheet is 250px tall.
- iOS 26.0 Simulator: The sheet is 250px tall.
My current workaround is to do this:
.sheet(isPresented: $showSheet) {
if #available(iOS 18.0, *) {
ChooseImageSheet(showSheet: $showSheet)
.presentationDetents([.height(250)])
} else {
ChooseImageSheet(showSheet: $showSheet)
}
}
It's not elegant having to repeat some code without a modifier on it in this way. Also, this forces the sheet to use the .large
detent, which fills the screen and isn't really appropriate for what I need to display in the sheet.
Sadly, I can't provide a sample project that exhibits this behaviour, as something as simple as this code doesn't exhibit it:
import SwiftUI
struct ContentView: View {
@State private var showSheet: Bool = false
var body: some View {
VStack {
Button {
showSheet.toggle()
} label: {
Text("Show the sheet")
}
}
.padding()
.sheet(isPresented: $showSheet) {
SheetView()
.presentationDetents([.height(200)])
}
}
}
struct SheetView: View {
var body: some View {
ZStack {
Color.blue.opacity(0.4)
Text("I'm the sheet! Hi!")
.foregroundStyle(Color.black)
}
.ignoresSafeArea()
}
}
#Preview {
ContentView()
}