Invalid Redeclaration of Struct Name

There has been an error that sometimes repeats itself. How can I remove it?

Struct Name: View {
some data ...

Struct ContentView: View {
... some data

struct ContentView_Previews:

       PreviewProvider {

    static var previews: some View {

        ContentView()

    }
}

struct Name: View {   //  <- inwalid redeclaration of Struct Name

   var body: some View {

      Text("Name")

   }

}

struct Name: View {     //    //  <- inwalid redeclaration of Struct Name

    var body: some View {

       Text("Name")

    }

}

Answered by Claude31 in 691271022

Does it work now ? If so, please close the thread.

There has been an error that sometimes repeats itself.

I don't understand.

Where does the repetition comes from ? Is it the code you try to compile, with 3 definitions for struct Name ?

If so, it is clearly a wrong code.

How can I remove it?

Just select other names:

struct Name2: View { 

   var body: some View {
      Text("Name 2")
   }
}

struct Name3: View {    

    var body: some View {
       Text("Name 3")
    }
}

And errors will go away.

Accepted Answer

Does it work now ? If so, please close the thread.

Invalid Redeclaration of Struct Name
 
 
Q