Xcode 6 with Swift super slow typing and autocompletion

后端 未结 11 1257
广开言路
广开言路 2020-11-30 19:05

Is it just me or Xcode 6 (6.0.1) with Swift seems to be super slow when you type your code, especially with autocompletion?

A normal Objective-C cla

相关标签:
11条回答
  • 2020-11-30 19:29

    Collapsing all methods helps a little.

    command-alt-shift-left arrow will do the trick...

    To fold/unfold current methods or if structures use:

    Fold: command-alt-left arrow

    Unfold: command-alt-right arrow

    0 讨论(0)
  • 2020-11-30 19:32
    • Quit Xcode and restart the Mac are not required but preferred.
    • Delete the content of the folder ~/Library/Developer/Xcode/DerivedData
    • Delete the content ~/Library/Caches/com.apple.dt.Xcode

    This is a temporally solution, but works greatly.

    Below the script using Script Editor app.

    tell application "Terminal"
        do script "rm -frd ~/Library/Developer/Xcode/DerivedData/*"
        do script "rm -frd ~/Library/Caches/com.apple.dt.Xcode/*"
    end tell
    

    Alternatively, you can create an alias for your terminal like this:

    alias xcodeclean="rm -frd ~/Library/Developer/Xcode/DerivedData/* && rm -frd ~/Library/Caches/com.apple.dt.Xcode/*"
    

    You can add that to your ~/.bash_profile and then type xcodeclean on the command line every time you would like to clear those two folders.

    0 讨论(0)
  • 2020-11-30 19:34

    I had the same issues even in Xcode 6.3

    • super slow autocompletions
    • super slow indexing
    • enormous CPU usage by swift and SourceKitService
    • enormous Memory usage by SourceKitService

    All this was happening even in relatively small project. I tried all the fixes I could find:

    • deleting ~/Library/Developer/Xcode/DerivedData/*
    • deleting ~/Library/Caches/com.apple.dt.Xcode/*
    • remove all "+" String combining from the code
    • removed all suspicious dictionary declarations

    None of these actually helped in my project.

    What actually solved my problem was:

    • placing each end every class in its own file
    • placing each and every extension in its own file (Class+ExtName.swift)
    • placing "out of class swift methods" in its own file

    Now I have close to zero CPU usage, low memory usage, and decently fast completions.

    0 讨论(0)
  • 2020-11-30 19:45

    Generally, moving the cache folder (DerivedData) to a SSD drive (specifically in my case - an outer storage connected to thunderbolt exit) has dramatically improved my Xcode performance.. Compilation time and general wondering around the app is about 10 time faster.. Also moved the whole git folder to the SSD, which dramatically improved git performance.

    0 讨论(0)
  • 2020-11-30 19:45

    SourceKitService is also kinda clumsy to deal with comments in the code and the embedded comments slow it down too.

    so if you can afford to remove the massive blob of embedded comments like this:

    /*
     * comment 
        /*
         * embedded comment
         */
     */
    

    that can definitely help as well.


    NOTE: in my case my Xcode 7.3.1 (7D1014) was literally blocked me typing any letter when the file had about 700 lines of comment with embedded comments. initially I removed that block from that .swift file and Xcode has become alive again. I tried added my comments back part by part by removing embedded comments, it was still slower than usual but it shown significantly better performance if there were no embedded comments.

    0 讨论(0)
提交回复
热议问题