If you have a day when your Mac hard drive is running out of space and you’re using Xcode a lot, try these steps to see if you can get some results.

I often get warnings about disk shortages, both because OF my frequent use of Xcode and because of other data I’ve accumulated on my computer. The data is not easy to delete, so I started from Xcode every time and sorted out a guide for my future operation. And I hope it helps you.

It has been verified in Xcode 11.1, and previously verified in Xcode 9 and Xcode 10.

Mainly operating two files in the directory ~ / Library/Developer/Xcode and ~ / Library/Developer/CoreSimulator.

Open the Finder app and use the command+ Shift + G shortcut to enter the path above to go to the corresponding folder.

1. ~/Library/Developer/Xcode

DerivedData

Each directory in this folder is a cache file generated when Xcode runs each APP. After deletion, running the APP will regenerate the corresponding file of the APP, but the compilation time will be longer.

You can keep the folders related to recently running apps. You are advised to clear the folders related to previously running apps that are no longer used, such as demo downloaded from the Internet.

Archives

The contents in this folder correspond to the package files listed in Xcode->Window->Organizer->Archives. Can retain useful package files, other delete.

iOS DeviceSupport

This folder stores the version support of Xcode for the real phone you are connected to. Each folder is almost several GIGABytes in size (in my case, 11 directories take up 26GB space). When the phone upgrades a version and connects to Xcode again, a directory will be generated here.

It is recommended to keep the current version of your phone’s folder. It doesn’t matter if you delete it all, it will be regenerated when your phone connects to Xcode again.

2. ~/Library/Developer/CoreSimulator

Devices

The directory under this folder is named after the UDID of the simulator. When running the simulator, each new APP is installed, the contents of the corresponding folder will also increase, just like the space occupied by installing apps on the mobile phone.

You can delete all folders. Run the emulator again and it will regenerate.

After deleting, start Xcode to run the emulator, the following error may appear, do not panic, restart Xcode is good.

.

You are advised to clean up after exiting Xcode and restart the PC.

I cleaned it up as I wrote this article, leaving over 30 G’s free. If you develop a project with Xcode for a year or two and never clean it up, it’s not an exaggeration to have 60GB or 70GB free.

Refer to the article: www.jianshu.com/p/8c633d29c…

Recommended reading

  • How to debug and upgrade a new version of iPhone on a real phone without upgrading Xcode
  • How to make your ObjC/Swift code look professional – highly recommended Xcode formatting tool XCFormat

 


I’m glad you finished reading this.

I am xi Yue, a program yuan.

At the age of 30, 2020 is a year of groping for progress, and we have set the flag of sharing articles with the stars.

If you are interested, please come to visit us often. We may have some sympathy as we grow up.

Our blog: Xiyuechen.net wechat official account “Stars and Evening moon”.