Initializer 'init(_:)' requires that 'Villager' conform to 'StringProtocol'

Hello.

I am fairly new to SwiftUI and wondering if someone can help out with this search functionality. I am currently attempting to pull a list from a json file and when setting up the logic for the search, I get

Initializer 'init(_:)' requires that 'Villager' conform to 'StringProtocol'

I am sure it may be a silly mistake but this is what I have:

struct ContentView: View {

    let villager: Villager

  @State var searchText = ""

  @State var searching = false

    

    var body: some View {

        

        //MARK: - PROPERTIES

        

        let villagers: [Villager] = Bundle.main.decode("villagers.json")

      

        

        //MARK: - BODY

        NavigationView {

            VStack {

                

                VStack(alignment: .leading) {

                    

                    SearchView(searchText: $searchText, searching: $searching)

                    

                    List {

//                        ForEach(villagers) { villager in

                        ForEach(villager.name({ (theVillagers: String) -> Bool in

                            return theVillagers.hasPrefix(searchText) || searchText ==  ""

                        }), id: .self) { Villager in

                            Text(Villager)

                            NavigationLink(destination: VillagerDetailView(villager: Villager)) {

                                VillagerListItemView(villager: Villager)

                            }

                                }

I think I am getting the error in the ForEach line but not entirely sure.

I appreciate the help

Your code causes bunch of errors -- Cannot find type 'Villager' in scope, Expected '}' in struct or Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project. And if I fix one error, many other errors generated. Please show enough code which can reproduce the error Initializer 'init(_:)' requires that 'Villager' conform to 'StringProtocol'. Please do not forget to use Code Block when you show some code.

Initializer 'init(_:)' requires that 'Villager' conform to 'StringProtocol'
 
 
Q