Debugging long compile times?

I look at the compile log in Xcode (under the "Reports" navigator), and it appears that one file is chewing about 30-40 seconds to compile. It's only 400 lines, but it has a lot of SwiftUI in it.

Is there any way to debug this? A way to log more info on why it's taking so long?

You've likely hit a type checker edge. Under "Other Swift Flags" in your project build settings you can add -Xfrontend -warn-long-function-bodies=100 and -Xfrontend -warn-long-expression-type-checking=100 (you'll need to separate each segment on separate lines) which will have the compiler emit warnings when functions or expressions take too long to type check. That should help narrow it down.

1 Like

Thanks! Right away, I saw this:

Expression took 33262ms to type-check (limit: 100ms)

The SwiftUI View tree expression was only about 40 lines long, but breaking it up is helping.

Sounds like a good sample for a bug report. If you post it we may be able to help. From what I've heard, lots of implicit Double -> CGFloat conversions can create issues in builders.

1 Like
Terms of Service

Privacy Policy

Cookie Policy