157
votes

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

30
Wasnt able to comment but this worked for me: dd if=/dev/zero of=./hugefile bs=100mSimon Prosser
Restarting mac will help :)Haseeb Javed
You will need at least 40gb to update if you downloaded it from appstoreZion TM
I have 41.82 GBs but still have the same issue, may be the latest version needs more than 40 GBAli Rehman

30 Answers

121
votes

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

105
votes

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

48
votes
  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

39
votes

I had 52 GB available (39 GB purgeable), but the stupid Mac App Store in macOS 10.14.4 still said it had not enough free space to complete my purchase of Xcode 10.2, even after a restart. Solution:

  • Quit the Mac App Store.
  • Delete directory ~/Library/Caches/storedownloadd
  • Relaunch Mac App Store.

My Xcode "purchase" then worked on the first try.

For the curious: At the time I deleted that directory, it did not contain any app downloads. It only contained a tiny (85 KB) SQLite database (.db, -shm and -wal files), which in turn contained four SQLite tables, three of which had zero rows and one of which had only one row and one column containing the schema version number! So this is apparently some weird bug in Mac App Store.

26
votes

Trying to update to xcode 11.3.1 today, was in the problem like this. However, I can confirm that the download starts right after free space reaches 24GB as per some of the comments above.

I did the following:
- remove ~/Library/Caches/storedownloadd
- remove ~/Library/Developer/Xcode/iOS DeviceSupport/
- remove some files inside ~/Library/Developer/Xcode/DerivedData
- remove other unused files

16
votes

the problem with time machine! please remove old snapshoots

sudo tmutil listlocalsnapshots /
com.apple.TimeMachine.2019-09-25-135035
com.apple.TimeMachine.2019-09-28-232824
com.apple.TimeMachine.2019-09-29-012547
com.apple.TimeMachine.2019-09-29-022054
com.apple.TimeMachine.2019-09-29-031621
com.apple.TimeMachine.2019-09-29-052318
com.apple.TimeMachine.2019-09-29-070831
com.apple.TimeMachine.2019-09-29-092229
com.apple.TimeMachine.2019-09-29-101756
com.apple.TimeMachine.2019-09-29-114952

tmutil deletelocalsnapshots 2019-09-25-135035
tmutil deletelocalsnapshots 2019-09-28-232824

etc

13
votes

I had the same problem (also a 120gb ssd), but 18gb is still not enough to install Xcode.

See this post: https://forums.developer.apple.com/thread/30235

12
votes

The same here for Xcode 11.2. It is mandatory to have at least 28GB free.

removing different directories such us, caches, .eclipse, .julia directories to free up.

UPDATE: 24GB with lastest version: 11.2.1

10
votes
  1. Quit App Store
  2. Delete both storedownloadd and storeassetd from ~/Library/Caches/
  3. Relaunch App Store
  4. Try again

The above steps resolved the issue for me.

MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)

macOS Mojave Version 10.14.6 (18G87)

7
votes

this command works perfectly, it removed AFPS snapshots

tmutil thinlocalsnapshots / 21474836480 4

Got the reference from this forum

https://forums.developer.apple.com/thread/110533

4
votes

For my case: I already have xcode 10.1 in my MBP.

  1. Delete directory ~/Library/Caches/storedownloadd and storeassetd directory in the same dir.
  2. Reopen the app store and go for the upgrade page.
  3. Download the xcode 10.2 from https://developer.apple.com/download/more/
  4. Somehow the app store will automatically install the xcode 10.2 right after download is finished.

Done.

4
votes

Mine is a weird solution. I did not have storedownloadd folder previous solutions talked about and manually downloading was not a real solution(what about future updates)

I manually created storedownloadd In the following directory re-started App Store, although loader took forever(restarted MacBook hoping for a change) it started downloading :)

~/Library/Caches/storedownloadd
4
votes

I solved it by upgrading MacOS as I'd have an old version installed. After a restart it magically had space :D (the same by the way)

3
votes

Try installing any other small app in the App Store and then install Xcode. It worked for me. In my case, I had 40 GB empty space but could not install Xcode due to the same error. Deleting ~/Library/Caches/storedownloadd did not work for me either.

3
votes

TL;DR: Deleting XCode (~7GB) and then the folder Users/[insert your mac username here]/Library/Developer (~90GB) freed around 100GB. I then installed XCode off of the App Store and it worked like a charm.

The answers above, such as rm hugefile did not work for me because I guess I had a legit memory issue. Downloading the XCode file and manually installing did not work because I still got the space/memory error.

I had about 10GB of free space according to Disk Utility.

Deleting XCode (I had it prior but had to update it) and other applications brought me to 17-20GB.

Still didn't work.

I had to go into the Users/[insert your mac username here]/Library/Developer and I deleted that directory, which I guess somehow saved XCode crap even though I deleted the application.

That brought me to a stunning 120GB.

120GB.

That is half of the memory on my hard drive.

?!

No idea how that works.

I then installed XCode directly off of the App Store and it works like a charm.

I guess be careful because I am not sure what is in that directory.. It did not seem important and all seemed XCode-related. It looked like simulators for XCode and other XCode related stuff. I am not sure. I use XCode A LOT so maybe error logs or usage logs built up. Even then - that's just text. So I am not sure. If I run into any weird issues that might result, I will post it here, but so far nothing.

Also, I highly recommend OmniDiskSweeper, which is a free program and is how I figured this out (among other memory-related issues in the past)

3
votes

Adding to @Biba's answer of directly downloading the version you want of Xcode from More Downloads for Apple Developers by signing in with your Apple ID.

First, delete Xcode application and then manually delete as much data as you can of Xcode located at ~/Developers. But even after that, you might not be able to save enough space for downloading and unpacking.

The file from Apple's site is a .xip file that needs to be unpacked and to get a Xcode.app file. Together they take well over 40 GB of space. And I could not clear that much space so I had to use an external drive to unpack the downloaded file. This process can take well over 1.5 hours to copy and unpack the file.

code unpacked file size

Once you get the Xcode.app file, copy it over to Applications using finder. It will first say, Preparing to copy to "Applications". After about 10 to 15 mins it will change to, Copying "Xcode" to "Applications". This should take another 30 - 40 mins. While you copy make sure you have a couple of extra GBs free. On the first load, it will open a popup, Verifying "Xcode.app". The verification takes 10-15 mins. Then it will ask for your Mac password to install additional components.

All the best. This is a really irritating update process.

2
votes

I ran into same issue trying to install XCode 11.beta after installing macOS Catalina. What i did:

  1. delete ~/Library/Caches/storedownloadd
  2. delete ~/Library/Caches/com.apple.appstore
  3. uninstall previous version of XCode (10.3) -> wait till all the files are deleted, can check in Disk Utility
  4. fresh restart -> without opening the apps before restart
  5. install new XCode version with Archive Utility.
2
votes

For Xcode 12 you need to have more than 32GB free space.

Delete the old Xcode application first.

Install OmniDiskSweeper which will show the total space used by the folders, which will be useful to detect the folders which occupy lot of space.

Go to Users -> your_user_name -> Library -> Developer (these are old xcode contents), delete all the contents here, since we are installing new xcode, the old contents are not necessary.

If you have Android Studio and willing to delete it, and install later, then delete the Android Studio application and on OmniDiskSweeper, go to Users -> your_user_name -> Library -> Android (these are old android studio contents), delete all the contents here.

Which will give you a lot disk space.

1
votes

I was literally at the same number today. I was able to download once I got my free space just over 20GB.

The issue for me was my Archives on some larger projects were taking up too much space. I will have to do a better purge, but just removing the failed uploads was enough to lower the system space and download the latest Xcode.

Here is a great link that explains this in further detail, as well as Simulator Cleanup and Derived Data.

Free Up Mac Storage

Sadly when I bought my Mac, I wish someone had told me to get over 250GB of space. All the recommendations said the 125GB was fine for running Xcode. Alright for learning iOS, but I guess they failed to evaluate large long term development.

1
votes

The App Store app does not account for the purgeable space. I have filed a feedback on this issue some weeks ago to the Apple Feedback Program: it seems fixed since macOS Catalina, as now it works without workaround.

For previous MacOS see this answer

1
votes

Same thing here, tried most of the above. 107 gigs of space free, but not enough to install.

So I downloaded Xcode from Apple directly (https://developer.apple.com/download/more/) and copied the .xip file to an external driven with lots of space.

I was then able to do this:

cd /Applications
xip -x "/Volumes/Blue 2T/Xcode_11.3.xip"

Don't forget to get rid of the xip file when you're done.

1
votes

It's not the prettiest solution, but I simply open Applications folder in Finder and drag Xcode to the bin, and delete it! :D

Then open App Store, find Xcode and install it again.

This still allows future updates from App Store. I have done this already multiple times over the last 6 years, especially for major version updates, as this always ended up being the simplest solution for me when I encounter such issues. This way you are not required to tamper with Developer folder data, unless you want to do some cleanup.

p.s. I found no harmful effects of this approach on my projects.

0
votes

For me, I had an extra folder in my Macintosh HD/Volumes/ folder, Im not sure how it was created, but it was some sort of copy of my external harddrive. After deleting it, I was able to download xcode

Hope this helps

0
votes

in my MacBook had 31 GB available (14 GB purgeable), macOS 10.14.5 still said it had not enough free space to complete my purchase of Xcode 10.2, just deleted directory ~/Library/Caches/storedownloadd, started downloading.

0
votes

Always late to the party, but anyway... i noticed a correlation with time machine backups, since i had a failed backup some time earlier and didn't connect my time machine hdd since.

After starting the Time Machine Backup and properly cancelling it soon after, i was able to install the update. Try it :)

0
votes

I also have this problem with a whopping 240GB available.

enter image description here

It seems that purging simply does not happen. I created a really big file, but it died because of no disk space:

paul-> dd if=/dev/zero of=~/zeroes bs=100M
dd: error writing '/Users/paul/zeroes': No space left on device
151+0 records in
150+0 records out
15728640000 bytes (16 GB, 15 GiB) copied, 33.0689 s, 476 MB/s
[~/Library/Caches ]
paul-> ls -lh ~/zeroes 
-rw-r--r-- 1 paul staff 15G Nov 17 09:27 /Users/paul/zeroes

It certainly should not have stopped at 15 GB

paul-> df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/disk1s1    466G  268G  197G  58% /
/dev/disk1s4    466G  1.1G  197G   1% /private/var/vm

Oddly enough, after removing the big file, I was able to download Xcode from the App Store.

0
votes

Additionally, Check the previous Xcode consumed storage through OmniDiskSweeper and delete unnecessary data and simulators that will free up too much size.

enter image description here

0
votes

After trying almost everything that i found can filter what exactly worked for me. Catalina 10.15.7 Xcode12.

  1. Go to your home folder in finder and make sure to enable hidden files shift + command + . //yes its a **dot** key on keyboard
  2. type dd if=/dev/zero of=/Users/<YOUR_USERNAME>/file bs=15m hit enter
  3. monitor the size growth of file named file in finder
  4. when it reaches something around 4-5GB kill the terminal with cntrl+c
  5. open disk utility and check purge size start copying and pasting that huge file named file that you just made and monitor the purge size. When it will get 3-4GB its now time to delete all that huge files and empty trash.
  6. restart
  7. open terminal go to /library/developer/
  8. delete all folder and files inside coreSimulator (this was the only resort for me)
  9. go to /library/developer/xcode/deriveddata and delete all folders and files inside
  10. empty trash

Go to App Store and update the Xcode.

0
votes

Just run below two commands in your terminal:

cd ~/Library/Developer

rm -rf Xcode
-1
votes

The same thing occurred to me when I was trying to install Xcode 12.0.1 from the app store even though I had around 40GB of free space and the Xcode 12 is taking only around 12GB. This helped me resolve the issue.

cd ~/Library/Developer
rm -rf Xcode

Hope this will help someone in need.

You can also open finder and click go to folder(shift+command+g), then type in ~/Library/Developer and clear everything there.