Xcode 8.0 Swift 3.0 slow indexing and building

后端 未结 16 2108
天涯浪人
天涯浪人 2020-12-07 17:12

I\'ve installed Xcode 8.0 and converted Swift 2.2 to 3.0 (that process also took a lot of time, I just left my Mac running all night). I have not a big project (about 20 fil

相关标签:
16条回答
  • 2020-12-07 17:28

    This works for me in Xcode 8.2.1 and Swift 3 when "Indexing" is stuck:

    I always have two projects open, a dummy project and the project I'm working on. I also have a iPad Air device connected that I run my projects on. When my project gets stuck on "Indexing", I switch to my dummy project and run my project on my connected iPad Air device. Then I stop the project and switch back to the project I'm working on and the "Indexing" is magically finished. This should also work with the simulator only, if you don't have a physical device connected.

    0 讨论(0)
  • 2020-12-07 17:29

    I had the same problem and solved it by painstakingly going through my code line by line, it turns out Swift 3 prefers string interpolation rather than using the + symbol, i.e.

    let url = "http://yahoo.com" + "someWebPage" + "whereItsInteresting" 
    

    If you have been using the above style of code replace it for;

    let url = "http://yahoo.com\(someWebPage)\(whereItsInteresting)"
    

    And your build time will immediately come back to normal.

    0 讨论(0)
  • 2020-12-07 17:33

    I encountered the same indexing issue, but it occurred only when I was running/debugging on a device and then switched to another device on the top-left toolbar (Target > iPhone).

    None of the solutions above worked for me.

    My solution: I removed my local git working copy and cloned a new one from my 'origin'.

    (There are some 'magic' files within the xcuserdata/shared/session etc. folders that may have caused this issue?)

    0 讨论(0)
  • 2020-12-07 17:34

    I've had the same issue only since upgrading to Swift 3/XCode 8 and it seems to be caused by large array literals.

    I was able to fix the issue by adding type annotations to the variables being assigned to the array literal, e.g.

    let array: Array<String> = ["1", "2", "3", "4", "5", "6", "7", "8"]
    

    instead of

    let array = ["1", "2", "3", "4", "5", "6", "7", "8"]
    
    0 讨论(0)
  • 2020-12-07 17:34

    for those who want to find where compiler is "caught"

    Add to Other Swift Flags -Xfrontend -warn-long-function-bodies=50

    check full answer here

    0 讨论(0)
  • 2020-12-07 17:36

    Backup your project delete the last update project after backup and then restart Xcode simple :-)

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