It's better to add conditional compilation.
In this way code will compile and work correct in Xcode 14 and 15.
extension WidgetConfiguration
{
func contentMarginsDisabledIfAvailable() -> some WidgetConfiguration
{
#if compiler(>=5.9) // Xcode 15
if #available(iOSApplicationExtension 17.0, *) {
return self.contentMarginsDisabled()
}
else {
return self
}
#else
return self
#endif
}
}