Xcode on Mac App Store can't install , show disk space not enough

I'm using the Mac OS to install the XCode10.1.

I have 18.43GB free disk space in the mac,

but when I click the install button on the Xcode from the app store,

it's always show the "Not enough storage disk space, you can't install the product" alert message.

How to fix the problem in the MacOS Mojave(10.14.1)?

Thank you very much.

enter image description here

enter image description here


Solution 1:

What you can also do is manually download Xcode and install it. (Without using the app store update) Therefor do the following steps:

  1. go to https://developer.apple.com/download/more/
  2. search for Xcode (or latest version e.g Xcode 10.2) and manually download and install it.

See also this post here: https://discussions.apple.com/thread/8622103?answerId=250008933022#250008933022

Solution 2:

Check the "purgeable" space of your APFS disk with Disk Utilities.. It seems Finder count this space in free space, but not App Store..

But you can trick macOS to clean up APFS by creating a huge garbage file, then deleting it.

To create the file I used the command:

dd if=/dev/zero of=/Users/<username>/hugefile bs=100m

letting dd run for about 30 seconds, then killing it with ctrl+c, and deleting the file:

rm ~/hugefile

Then App Store happily installed update..

Solution 3:

  1. Open finder: in menu above go to -> Go to folder:

    ~/Library/Developer/Xcode/

  2. Delete old simulator files on:

    ~/Library/Developer/Xcode/iOS DeviceSupport/

  3. Delete all files derived data on:

    ~/Library/Developer/Xcode/DerivedData

An easy way to accomplish these is by using DevCleaner for Xcode: https://apps.apple.com/us/app/devcleaner/id1388020431?mt=12