resultBuilder debugging pain

In using resultBuilders, primarily ViewBuilder, my biggest pain point is that internal problems are obscured by type inference error messages. Instead of being told where things broke down, I just get told it can't figure out the whole block.

This must be pretty pervasive, is there an efficient way to debug this?

I'm trying to make structural changes to a medium sized code base, and this means statements can suddenly be wrong that were right before. I just need to compiler to say, "yo, this here doesn't make sense" with useful specificity. Then I can go fix it.

2 Likes

the only way I've managed to debug these things is to comment out one item at a time in the result builder until the compiler can find what's wrong.

Definitely a major headache and something I wish the compiler could do for me.

2 Likes

I normally comment out the whole view body besides the top level element and then go step for step until it fails.
Then I know which part is failing and comment out everything besides the minimal setup to get this part working.
Then I get the error message. But I started to keep my view bodies really small and build everything up with var xxx: some View.

It is a major painpoint with SwiftUI and I wish there were some easier solution.

1 Like