Reputation: 20710
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?
Upvotes: 5
Views: 1095
Reputation: 20710
In this case it had something to do with CocoaPods
. It was copying .h
files into the build directory and SourceKit
was getting confused.
I added this script to my project, and SourceKit
stopped freaking out a bit, but it is still ridiculously slow.
function removeHeaders() {
find $BUILD_ROOT/Debug-iphonesimulator/ -name '*.h' -exec rm -f {} \;
}
removeHeaders
Ref. Xcode Swift Syntax Highlighting and Code Completion Completely Broken
Note: Unfortunately this solution breaks debugging console and archiving. So remove the script if it is needed.
Upvotes: 0
Reputation: 7746
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.
Upvotes: 4