XCode errors everywhere even is starting project

This morning I wanted to continue working on my project, but XCode suddenly showed me a lot of errors. They were absolutely silly errors, like Image doesn't have .resizable modifier e.t.c. Then I started a new project to make sure my project is OK, and yes, XCode was full of errors even in its starting project. I attached the screenshot of the phenomenon.

What I tried so far:

  • Clean build folder
  • Quit and restart XCode
  • I used DevCleaner
  • Restart machine
  • Uninstall and reinstall XCode

to no avail.

Do you have any ides? Thanks.

Answered by hastoro11 in 774962022

I figured it out. To be honest this ContentView was the original XCode generated view, but what I did not take into account that I created and added a new file with some model structs in it. And it the model there was pproperty which was named Image (I usually use app.quicktype.io to generate structs from JSON). This Image struct was in conflict with the SwiftUI original Image struct. And XCode got just confused rather than warning me about the conflict. Thank you for thinking about my problem!

I tested your code:

        VStack {
            Image(systemName:"globe")
                .imageScale(.large)
                .foregroundStyle(.tint)
            Text ("Hello, world!")
        }
            .padding()

It works in Xcode 14.2.

Which version off Xcode do you use ?

15.1, the last stable version. When I reverted to the 15.0.1 version it worked again. But it was scary to see in my project I'm working on, that everything fell apart. Dozens of errors like these popped up.

It's not my code by the way, it's the starting project of XCode. Just wanted to show that the problem is not code dependent.

Maybe the XCode does not find something, some settings or some library.

Accepted Answer

I figured it out. To be honest this ContentView was the original XCode generated view, but what I did not take into account that I created and added a new file with some model structs in it. And it the model there was pproperty which was named Image (I usually use app.quicktype.io to generate structs from JSON). This Image struct was in conflict with the SwiftUI original Image struct. And XCode got just confused rather than warning me about the conflict. Thank you for thinking about my problem!

Thanks for the feedback. So, logically, it did work in my environment.

It is effectively a very risky practice to reuse the name of a system class or struct for a new one.

Another lesson, is that it is important to explain the context of the app, not just a partial view of the code where the problem shows.

Good continuation. Don't forget to close the thread.

XCode errors everywhere even is starting project
 
 
Q