Massive CPU usage and can't even do basic code completion

I have recently encountered a similar problem.

At some point, my project started to take an insane amount of time to compile, that it seemed unreasonable for its size. I have checked what takes it so long and found out that swift-frontend spends much time in type checking.

The solution is to not rely on type inference in swift as it is unstable and annotate every single variable manually. After I did, my build time decreased from minutes to seconds, it was a 4000x improvement, in fact!

So you have two options relly: don't use swift or don't use type inference. Pick one that is appropriate for you.

Look at this marvel!


And after I put annotations:
Screen Shot 2021-11-15 at 01.10.26


Your problem with sourcekit was caused by the fact that this thing uses type checking for completions and it was basically stuck.

1 Like