• Home
  • MAD
    • IOS Series
    • Android Series
    • Flutter Series
    • Xamarin Series
  • Concept Series
    • Software Design
    • Software Arch
    • GIT & Github
    • System Design
    • Cloud
    • Database Integration
    • Push Notification
    • API Integration
    • Cocoa PODS
  • DSA
  • Interview
  • Tips&Tricks
  • YT
  • Home
  • MAD
    • IOS Series
    • Android Series
    • Flutter Series
    • Xamarin Series
  • Concept Series
    • Software Design
    • Software Arch
    • GIT & Github
    • System Design
    • Cloud
    • Database Integration
    • Push Notification
    • API Integration
    • Cocoa PODS
  • DSA
  • Interview
  • Tips&Tricks
  • YT
  • #News
  • #APPS
  • #Events
    • #WWDC
    • #I/O
    • #Ignite
  • #Let’s Talk

MyCodeTips mycodetips-newlogocopy1

  • Home
  • MAD
    • IOS Series
    • Android Series
    • Flutter Series
    • Xamarin Series
  • Concept Series
    • Software Design
    • Software Arch
    • GIT & Github
    • System Design
    • Cloud
    • Database Integration
    • Push Notification
    • API Integration
    • Cocoa PODS
  • DSA
  • Interview
  • Tips&Tricks
  • YT
Tips&Tricks, Quick Tips, XCode

How to clean Xcode Cache or Temporary files.

Recently I had this problem and my first reflex is finding a script or an app to “clean” my Mac. It helps a bit but not much, since theses apps can only give you “safe” cleaning, typically removing caches data. Xcode takes a lot of space on your hard drive. From time to time you could see warnings about low storage.

Xcode Caches

It’s safe to delete the folder com.apple.dt.Xcode because Xcode can recreate its caches (it could take some time at first relaunch, if Xcode need to re-download something).
The location of this folder is at ~/Library/Caches/com.apple.dt.Xcode

Clean the build

it’s worth cleaning the project build first. This will get rid of the current build and create a new one the next time you run the code.

With the project open in code, go to the menu bar, choose Product, and select Clean.

With the project open, press Command + Shift + K.

Clean out the build folder

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

In the Code project, click on the Product menu while holding down the Option (Alt) key and choose Clean build folder, or:

Press Command + Shift + Option + K.

Clean out the build folder

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.

Reset Simulator content and settings

Delete Xcode’s derived data

Derived Data is the place for all temporary build info and project indexes. If something’s not working right, it is okay to delete this folder.

Xcode Cache , Contents of Derived Data folder is generated while Xcode builds your project, so it’s safe to empty it.
The location of this folder is at ~/Library/Developer/Xcode/DerivedData

So if you’re still having problems or things are working slow, try deleting derived data, which will force Xcode to recreate it when you next run it.

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

derived data

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

derived data

Delete iOS device support files

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.

The location of this folder are at ~/Library/Developer/Xcode/iOS DeviceSupport/

Use Terminal

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

Launch Terminal from Applications > Utilities
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.

Additional Simulators

Sometimes you need to download additional simulator of older iOS versions to test your apps. But when you no longer need those simulators, it’s good idea to get rid of them. A simulator takes approximately same size as the iOS.
The location of this folder are at /Library/Developer/CoreSimulator/Profiles/Runtimes (be careful, the path is /Library, not ~/Library)

Xcode Archives

Xcode Cache or Archives could take a lot of spaces. Since you always generate an archive for every release, over time it can cumulate to a big mountain. You can delete them by going to Organizer -> Archives tab -> right-click on the archive you want to delete -> Open in Finder -> remove the .xcarchive file
The location of this folder is at ~/Library/Developer/Xcode/Archives

Happy Reading 🙂

Liked it? Take a second to support Ranjan on Patreon!
become a patron button
  • Click to share on Reddit (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • More
  • Click to share on Pocket (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
Written by Ranjan - 24106 Views
Tags | Tips & Tricks, Xcode
AUTHOR
Ranjan

Namaste, My name is Ranjan, I am a graduate from NIT Rourkela. This website is basically about of what i learnt from my years of experience as a software engineer on software development specifically on mobile application development, design patterns/architectures, its changing scenarios, security, troubleshooting, tools, tips&tricks and many more.

You Might Also Like

structures-classes-enum

Structures and Classes in swift !

November 22, 2021
mycodetips-newlogo2

Use Your MAC Without a Mouse-Part2

October 16, 2013
objective-c-datatypes1

Objective-C Data Types

November 12, 2021
Next Post
Previous Post

Support us

mycodetips
mycodetips

Follow us @ LinkedIn 2850+

Subscribe for updates

Join 8,213 other subscribers

Latest Posts

  • YT-Featured-solidprinciples
    SOLID Principles of Software Design
  • IOS 16 Features
    Latest features in IOS 16
  • r-language
    How can R language be used for data analysis?
  • wordpress-coding-blog
    Guide To WordPress Coding Standards
  • YT-Featured-Algorithm
    What is Algorithm?
  • Frameworks of IOS
    Frameworks of IOS – Part ( I )
  • NSFileManager or NSPathUtilities
    NSFileManager or NSPathUtilities in Objective-C
  • Passing data between view controllers in Objective-C
    Passing data between view controllers in Objective-C
  • structures-classes-enum
    Structures and Classes in swift !
  • control-system-swift
    Control Flow in Swift
whiteboard

Whiteboard(PRO)

whiteboard

Whiteboard(lite)

alphabets

Kids Alphabet

techlynk

Techlynk

techbyte

Do2Day

techbyte

Techbyte

  • #about
  • #myapps
  • #contact
  • #privacy
  • #Advertise
  • #myQuestions

Android Android Studio API APP Programming Apps blogging CSS DATABASE dsa Features HTML HTML5 installation Interview Questions IOS iPhone javascript Mac objective-c OS Programming quicktips SDK SEO SQL swift Tips & Tricks Tools UI Web Wordpress Xcode

  • SOLID Principles of Software Design
  • Latest features in IOS 16
  • How can R language be used for data analysis?
  • Guide To WordPress Coding Standards
  • What is Algorithm?

©mycodetips.com