Firstly, please ignore the pre-release Public Beta; it's irrelevant. The fact that a friend of yours is running it is irrelevant. It is not a supported version of iOS, and you should not be developing against it.
Think about it... Apple might release ten betas of iOS 27; are you going to write your apps so that they run on all ten betas, even though no one will be running those betas anymore?
Your friend should not be running the Public Beta. It is not supported, and you should not support it either.
Secondly, the way to correctly make sure your app doesn't crash on different versions of iOS is to test your app. Xcode allows you to use multiple Simulators which will let you catch most issues.
Also, you can use code such as if #available(iOS 26.0, *) to conditionally run code that applies only if that version of iOS is available on the device. If it isn't, you run some other code. I do this all the time. I have a function like this:
func olderiOS() -> Bool {
if #available(iOS 26.0, *) {
return false
}
return true
}
// Create a global var to use it so we don't keep running the check:
let isOlderiOS: Bool = olderiOS()
I use it for inline checks, such as: .padding(.top, (isOlderiOS ? 10 : 5) where you can't use if #available().
Finally, you can apply conditional modifiers to code. Something like this:
public struct Additional<Content> {
public let content: Content
public init(_ content: Content) {
self.content = content
}
}
extension View {
var additional: Additional<Self> { Additional(self) }
}
extension Additional where Content: View {
@ViewBuilder func presentationDetents_before_iOS18_0(height: CGFloat) -> some View {
if #available(iOS 18.0, *) {
content
.presentationDetents([.height(height)])
} else {
content
}
}
}
I've created the presentationDetents_before_iOS18_0 modifier because you can't use the .presentationDetents modifier before iOS 18, so this function applies it if iOS 18.0+ is available, and doesn't if we're on iOS 17 or below. I use it like this:
.sheet(isPresented: $showSheet) {
ChooseImageSheet(showSheet: $showSheet)
.additional.presentationDetents_before_iOS18_0(height: 400)
}
There might be easier ways to do some of this, but it works for me.