Static method 'buildBlock' requires that 'Group' conform to 'View'

I'm Trying add SwiftUI to Old Project.

But Error in Group.

How do I solve this problem?

My Project:

  • Xcode: 12.5.1
  • iOS Deployment Target: 13.0

Swift Compiler Error

  • Static method 'buildBlock' requires that 'Group' conform to 'View'

  • Trailing closure passed to parameter of type 'NSManagedObjectContext' that does not accept a closure

Answered by OOPer in 689677022

As far as I read the messages, it looks like you have another type named Group (which is an NSManagedObject -- Core Data entity) in your project.

Please try something like this:

struct LostFindView: View {
    var body: some View {
        VStack {
            SwiftUI.Group { //<-
                Text("1")
                Text("2")
                Text("3")
                Text("4")
                Text("5")
                Text("6")
                Text("7")
                Text("8")
                Text("9")
                Text("10")
            }
            Text("11")
        }
    }
}

Please use Code Block when you show some code, better read the hint from @robnotyou.

struct LostFindView: View {
    var body: some View {
        VStack {
            Group {
                Text("1")
                Text("2")
                Text("3")
                Text("4")
                Text("5")
                Text("6")
                Text("7")
                Text("8")
                Text("9")
                Text("10")
            }
            Text("11")
        }
    }
}

struct LostFindView_Previews: PreviewProvider {
    static var previews: some View {
        LostFindView()
    }
}

It works for me... builds cleanly.

Try the usual:

  • Product > Clean Build Folder
  • Quit Xcode, reload and try again

Hint:
It's better to paste the actual code, in a code block (rather than a screenshot).
Then people who are trying to help you can easily copy-and-paste your code, to try it out.

Ah...
Could it be your deployment target?
Try setting it to iOS 14, and see what happens.

Accepted Answer

As far as I read the messages, it looks like you have another type named Group (which is an NSManagedObject -- Core Data entity) in your project.

Please try something like this:

struct LostFindView: View {
    var body: some View {
        VStack {
            SwiftUI.Group { //<-
                Text("1")
                Text("2")
                Text("3")
                Text("4")
                Text("5")
                Text("6")
                Text("7")
                Text("8")
                Text("9")
                Text("10")
            }
            Text("11")
        }
    }
}

Please use Code Block when you show some code, better read the hint from @robnotyou.

Static method 'buildBlock' requires that 'Group' conform to 'View'
 
 
Q