Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Compiler stuck::considering giving up on SwiftUI

Apologies if this comes off as a bit of a rant, and TLDR: Compiler hangs or gives an unhelpful error with any level of complexity in SwiftUI - which makes me want to back to IB

Porting a project over to iPhone. Made great progress the first week. However, lately I have been encountering compiler bugs where either the build never finishes, or the build take a really long time and ends with just the error : The compiler is unable to type-check this expression in reasonable time

Sometimes I can get it to go away by playing divide and conquer and finding some small error, but other times with my nested scrollview it just seems unhappy with any level of complexity (and I don't think my views are all that complex compared to lots of other apps out there)

I've read several posts on these forums for things to try and do to fix it but the bottom line is its impacting my ability to produce a working solution in a reasonable amount of time. So considering going back to Interface Builder though it means starting over with some of the code.

If there was another independent way to syntax check my swiftUI code other than line by line myself I'd welcome something like that. The compiler going away and never coming back is very discouraging -- what if I have to make some kind of emergency fix in the future with limited time?

Open for any suggestions.

Xcode : 16.2

Answered by ssmith_c in 838176022

yes to splitting up views into smaller chunks. They can be easier to test that way.

I've often pasted non-working code into Copilot and asked "why doesn't this compile?". LLMs are quite good a pointing out errant commas and the like, where a compiler will often give you an entirely logical, but useless error message (unless you write compilers for a living).

It's going to be a big challenge to port an existing project to SwiftUI. What you describe makes a lot of sense. Most people never encounter this error anymore because they are starting small, with a new project.

That being said, you specifically said that you were "porting a project over to iPhone". I don't think trying to do that kind of massive port from a foreign architecture is going to be any more pleasant in UIKit.

I recommend starting small, with a new project. Build the bones of your UI to match the old project. But don't attempt to port the entire thing at once. Follow the path of least resistance and write the code the way SwiftUI or UIKit expects.

Thanks. I was able to divide and conquer (again) and get the compiler unstuck. Dividing up the work is helping. Hopefully I won't encounter that agin if I keep subdividing my views

yes to splitting up views into smaller chunks. They can be easier to test that way.

I've often pasted non-working code into Copilot and asked "why doesn't this compile?". LLMs are quite good a pointing out errant commas and the like, where a compiler will often give you an entirely logical, but useless error message (unless you write compilers for a living).

Compiler stuck::considering giving up on SwiftUI
 
 
Q