Home Topic Funny Feeling
Clear Xcode cache Folder
header
XiaoTian 01.09

How to clear Xcode cache manually

#1. Clean the build

Tip: If you’re trying to fix a problem with Xcode crashing, it’s worth cleaning the project build first. This will get rid of the current build and create a new one next time you run the code.

  1. With the project open in code, go to the menu bar, choose Product, and select Clean or:
  2. With the project open, press Command + Shift + K.

#2. Clean out the build folder

To clean out the build folder, and get rid of cache files, do the following:

  1. In the Code project, click on the Product menu while holding down the Option (Alt) key and choose Clean build folder, or:
  2. Press Command + Shift + Option + K. 

#3. Reset Simulator content and settings

If neither of the steps above resolves your problem, try resetting the simulator content and settings:

Go to the menu and choose iOS Simulator, then click Reset Content and Settings.

#4. Delete derived data

If you’re still having problems, try deleting derived data, which will force Xcode to recreate it when you next run it. 

  1. In the menu, choose Window, then Organizer.
  2. Now select Projects, and then click Select your project.
  3. Choose the project whose derived data you want to delete.
  4. In the window that opens, you’ll see see the Derived Data folder listed, along with its Finder path.
  5. To the right of the folder, there’s a Delete button. Press it.

Now, delete the module cache.

  1. Go to: ~/Library/Developer/Xcode/DerivedData/ModuleCache.
  2. Drag the files from the ModuleCache folder to the Trash and empty it.

#5. iOS device support

There’s another folder inside DerivedData, called iOS device support. For every iOS version you test using the simulator, a new folder is created inside this folder. That can build up over time. You can delete all these subfolders (though, not the iOS device support folder itself) and Xcode will create a new one the next time you run the simulator. If you’re uncomfortable deleting them completely, you can move them to a temporary folder until you’re sure that moving them hasn’t caused any problems, and then delete them afterwards. 

  1. Go to:  ~/Library/Developer/Xcode/iOS DeviceSupport

#6. iOS Archives Packages

You need to unbelieve that. You can make an .ipa file from your app's archive, but you don't usually need to do that any more.

Alternatively, open XCode, go to Window->Organizer. Right-click the archive you are looking for and select "Show in Finder"

Go to:  ~/Library/Developer/Xcode/Archives

#7. Use Terminal

If none of the above helps, you can use Terminal to reset Xcode’s preferences.

  1. Launch Terminal from Applications > Utilities
  2. Type: defaults delete com.apple.dt.Xcode 

When you next launch Xcode, it will create new preferences. 

There is also a method of cleaning cache files that involves navigating to ‘private/var/folders’ (use the Go menu in the Finder and choose Go to Folder, then type that path), digging through folders until you find an Xcode cache file and deleting it. However, we wouldn’t recommend this route unless you are absolutely certain you know what you’re doing. Removing the wrong file can create lots of problems, not just in Xcode but in the OS as a whole. In some instances, users who have done that have had to reinstall macOS from scratch. 

created h 01.09
last reply h
0 replies
0 users
91 views
Reply