New to swiftui. How do I solve this?
struct ContentView: View {
var body: some View {
HStack {
VStack {
Text("Hello World")
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
VStack {
Button(action: {
self.volumeCheck()
}) {
Image("chimes")
.renderingMode(Image.TemplateRenderingMode?.init(Image.TemplateRenderingMode.original))
}
Button(action: {
self.volumeCheck()
}) {
Text("Click chimes to test volume")
}
}
}
}
func volumeCheck() {
}
}
Report
static method 'buildBlock' requires that 'Button<Any>.Type' conform to 'View'
----------------------------------------
failedToBuildDylib: /Users/scottlydon/Library/Autosave Information/SmartWorkTimer/SmartWorkTimer/ContentView.swift:18:20: error: static method 'buildBlock' requires that 'Button<Any>.Type' conform to 'View'
VStack {
^
SwiftUI.ViewBuilder:3:24: note: where 'C1' = 'Button<Any>.Type'
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleView<(C0, C1)> where C0 : View, C1 : View
^
/Users/scottlydon/Library/Autosave Information/SmartWorkTimer/SmartWorkTimer/ContentView.swift:26:17: error: generic parameter 'Label' could not be inferred
Button
^
/Users/scottlydon/Library/Autosave Information/SmartWorkTimer/SmartWorkTimer/ContentView.swift:26:17: note: explicitly specify the generic arguments to fix this issue
Button
^
<<#Label: View#>>
I've met this same bug (Static method 'buildBlock' requires that 'Button' conform to 'View') with Xcode 13.1. Not with all projects, just with some. Amazingly what helped me is to use Button the following way (just prefixed with SwiftUI):
SwiftUI.Button
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With