Post

Replies

Boosts

Views

Activity

Reply to The compiler is unable to type-check this expression in reasonable time in Xcode 12 with SwiftUI
I've read through all the replies and not a single person has explained this error correctly, so I will do so. Irrespective of whether the code that has been pasted to this thread is correct, incorrect, has bugs, etc. this error is not about bugs in the code. This error occurs when a single block is too complex for the compiler to type check in a reasonable amount of time. Again, what is a reasonable amount of time? I don't know. But I see a lot of code here with all manner of things and complicated code in one view. This is what causes that error. You want to break out as much of your UI setup as possible into separate views. And your main view whether it be a component or whether it be ContentView, it should look like this: var body = some view { view1 view2 view3 ... } Here's a real example from the app I am creating where I used to get the same error in this view that a lot of you are getting: struct ContentView: View { // Application State var body: some View { ZStack { Color.black.edgesIgnoringSafeArea(.all) HStack(spacing: 20) { bosses itemGrid gameOptions } } .padding(0) } } And then bosses, itemGrid, and gameOptions are other views specified above ContentView in the same file. Apparently you cannot have any one block be overly complex and you have to break it apart into different pieces that are pieced together in the main view.
Oct ’24