I'm seeing a strange crash only can repro on iOS 14 with debug mode...
Anything I can do to work around it?
Demo project:
https://github.com/imWildCat/GetOpaqueTypeMetadataSwiftUICrash
I'm seeing a strange crash only can repro on iOS 14 with debug mode...
Anything I can do to work around it?
Demo project:
https://github.com/imWildCat/GetOpaqueTypeMetadataSwiftUICrash
I managed to fix this crash by using custom ViewModifier
public extension View {
@ViewBuilder
func searchableFor15(text: Binding<String>) -> some View {
if #available(iOS 15, *) {
self
.modifier(SearchModifier(text: text))
} else {
self
.modifier(NoSearchModifier())
}
}
}
@available(iOS 15, *)
private struct SearchModifier: ViewModifier {
let text: Binding<String>
func body(content: Content) -> some View {
content
.searchable(text: text)
}
}
private struct NoSearchModifier: ViewModifier {
func body(content: Content) -> some View {
content
}
}