Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's wrong with the syntax highlighter and autocompletion in Xcode using Swift

When developing a project in Objective-C everything is smooth, SourceKitService is taking 0% of CPU, autocompletion is almost instant.

But if I change a Swift code a bit, it takes many seconds to do anything (highlight syntax and check, whisper etc.) Or when i want to see an implementation of something with cmd shortcut, again SourceKitService on xxx% of CPU and takes seconds. Changing a character in code leads to 10 seconds of waiting to see everything is ok is too much.

Sure I tried to delete derivedData, ModuleCache, com.apple.dt.Xcode etc. as advised but it is not permafix, still happening, slowing me down.

Does anybody know how to really fix this issue or at least improve it?

like image 818
Jakub Truhlář Avatar asked Oct 29 '22 12:10

Jakub Truhlář


1 Answers

I would recommend trying the Build Time Analyzer to see if there are specific things slowing down the compiler. In my experience the main problem is complex Type inference, usually from multiple chained .maps, complex associated types and, generics.

The Swift compiler is doing a lot more and is quite a bit newer than the Objective-C compiler so it unlikely it will be as stable/fast for quite some time. I know compile time and IDE stability is something they're aware is a problem and are working to improve. Hopefully now that we have (promised) source compatibility some of this things will be fixed our greatly improved within the next year. Unfortunately we'll probably have to jump through some hoops until that point.

like image 78
GetSwifty Avatar answered Nov 15 '22 07:11

GetSwifty