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 ?

enter image description here

enter image description here

  • Can you add a screenshot from Activity Monitor or similar with some details about this process? Does it start right after login, or only while Xcode is running? – nohillside Dec 12 '19 at 13:48
  • It starts when i open Xcode and Xcode starts either indexing or building files. I will attach a screenshot when possible – Cristian Bănărescu Dec 12 '19 at 13:53

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..

New ones:

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.

  • Hi! I did what you said here and I am still getting the same frustration: The swift process starts to run and occupy a lot of my memory. I could not find any issues in my code that may cause this. I read about the issues that I may find ( the links you provided ) but I was not able to 'reproduce' the issue that is causing my swift process to start. Maybe you can give me more details on how to trace the issues – Cristian Bănărescu Dec 16 '19 at 10:33
  • I am not aware of the issues in Swift or Xcode for that matter, unfortunately. You should revisit the questions, their "Linked" ones in the sidebar and then edit in the question what you've tried. I think this would not be very old to be migrated to SO. Also, see latest edit. – anki Dec 16 '19 at 11:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .