简体   繁体   中英

Xcode internal errors when testing with swift

I started having peculiar problems when using XCode. Whenever I try to write test with swift, XCode shows an internal error and all the code turns white.

This happens even if I remove the @testable annotation from the code.

I tried reinstalling XCode, but this did not help. The code builds just fine so I don't have a clue where the problem might lie.

I'm unable to properly develop tests this way, my modules are not recognised, I have no error checking or code completion.

Here is a screenshot of how the problem looks: XCode错误

Would love to get any guidance on this issue...

So I guess for now there is no good solution to this problem. It seems to be caused by crashes of SourceKit.

Fortunately the problem is not solved (partially) on my end.

I decided to make this answer a compilation of different things to try when experiencing this:

  • Restart - try restarting both Xcode and the PC
  • Clean the project (shift-command-K)
  • Build your code, I noticed that sometimes it occurs when you just have unrelated build errors somewhere in your project - make sure it builds
  • Delete the DerivedData folder rm -Rf ~/Library/Developer/Xcode/DerivedData/ , but you can also delete it from Xcode
  • Delete the cache rm -Rf ~/Library/Caches/com.apple.dt.Xcode - Currently this seems to help the most

I will edit and add more solutions if I find any

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM