Mac swift process blocks system, high memory pressure Recently, since XCode 11, my Mac starts a process (it seems like it does so when indexing or building files) called swift and my Mac soon starts to lag. This process gathers a lot of memory (sometimes it gathers up to 70 GB) from my computer and I have to kill the process every time in order to get back to normal and start using my Mac as before.

How do I stop this memory pressure from increasing this much ?
To clean your build in Xcode (under Product menu) and deleting cache in ~/Library/Developer/Xcode/DerivedData/ (not the whole Developer folder, as it has simulators etc. too) was my original suggestion. 

Finding on Stack Overflow got me these: 


Restart your Mac. 
After making a copy of your project in a safe place, right click on the project file and select "Show Package Contents". Delete the .xcworkspace file and rebuild your project. Use the backup file if it persists.
Bugs in Swift which can be triggered by 


Declaring arrays in multiple lines
Programming errors. 
Several concatenations in one line

  ...it was caused by a 20 item array literal. Had to switch to different syntax. 




and so on.. 


https://stackoverflow.com/questions/24782721/xcode-swift-indexing-forever
https://stackoverflow.com/questions/13831559/xcode-stuck-on-indexing
https://stackoverflow.com/questions/26494082/swift-xcode-index-freezing-or-slow


New ones: 


https://stackoverflow.com/questions/58874341/xcode-indexing-takes-ages-and-uses-gigabytes-of-memory says cocoapods. 
And https://stackoverflow.com/questions/58649756/xcode-uses-huge-ram-memory-90gb This and some under the search Xcode swift memory indicate that it might be a new bug.


Your best bet is to use search and sort feature on SO, see linked and suggested questions to find problems in your code. Might even want to use source control to move back to the part where it was not problematic. After you've exhausted your search and trials, edit the question, I'd put a bounty. If it is not helpful, ask mods to kindly migrate.