[xcode] How to Empty Caches and Clean All Targets Xcode 4 and later

Jonathan suggest here: Xcode Includes .xib files that have been deleted! that cleaning all targets and empty the caches will fix the problem with Xcode including deleted .xib files but I cannot find a way to empty the cache in Xcode 4.

How to do that in Xcode 4?

This question is related to xcode caching xcode4 xib

The answer is


I have been pulling out hair from my head because I thought that I had the same problem. When building the app I didn't get the same result on my iPhone as on the simulator.

The problem was that I had somehow made a localized version of the MainStoryboard.storyboard file. So when I ran the app on my phone it showed the danish version... and the simulator showed the english version.

Yeah I'm new! :)


In addition to doing the following, you may experience this issue if your app's Storyboard's files are localized. First, do each of these:

  • Clean Build
  • Reset Simulator
  • Restart Xcode
  • Delete your DerivedData folder in ~/Library/Developer/Xcode/DerivedData
  • Restart Computer

What finally worked for me was re-generating the storyboard localization files and deleting the English localization (which was unneeded because the Base Locale is English). To reload your Storyboard strings, see this answer on StackOverflow.

I had noticed that the non-text parts of my Storyboard were being updated, but not the localized text. If you have a localization in your app, I would recommend checking to make sure your localizations are updated (even if they're .strings files).


When using a "Data Model" , there are options in the inspector to generare classes, for me this was the case as there was already a class with the existing name.

Codegen: solved it for me.

enter image description here


You have to be careful about the xib file. I tried all the above and nothing worked for me. I was using custom UIButtons defined in the xib, and realized it might be related to the fact that I had assigned attributes there which were not changing programmatically. If you've defined images or text there, remove them. When I did, my programmatic changes began to take effect.


Here's my shell script solution, which deletes derived data and cleans a project's cached assets, for Xcode 4, 5 and 6.

Sometimes, simply calling rm -rf on the Derived Data directory leaves a lingering file or two, but my script loops until all files are deleted.


To delete all derived data and the module cache in /var/folders use this little ruby script.

derivedDataFolder = Dir.glob(Dir.home + "/Library/Developer/Xcode/DerivedData/*")
moduleCache = Dir.glob("/var/folders/**/com.apple.DeveloperTools*")
FileUtils.rm_rf derivedDataFolder + moduleCache

This just solved a fatal error: malformed or corrupted AST file: 'Unable to load module "/var/folders/ error for me.


Command-Option-Shift-K should do it. Alternatively, go to product menu, press the option key, now the option "Clean" will change to "Clean Build Folder ..." select that option.


I found another way in addition to command+option+shift+K. In XCode 4.2 there is an organizer that can be opened from top-right icon. You can clean all archives and saved project options from there. This helped my situation (I was seeing old removed files in the mainBundle).


My "DerivedData" with Xcode 10.2 and Mojave was here:

MacHD/Users/[MyUser]/Library/Developer/Xcode


I tried almost everything but could not help,what helped me was disabling SIP(System Integration Protection) n it works,I do not know what happens when and how but system file get confused somewhere and causes this...though there might be risks to disabling this obviously

here is how

1.Power on your Mac and hold down the [command]+[R] keys to access the Recovery Partition.

2.From the Recovery Partition, click Utilities from the menu bar, and then select Terminal.

3.Enter the following command into Terminal and press Enter to execute it: csrutil disable

4.Once the command has executed, exit the Terminal and reboot the Mac. When you log back into OS X, SIP will be disabled.


I had some problems with Xcode 5.1 crashing on me, when I opened the doc window.

I am not sure of the cause of it, because I was also updating docsets, while I opened the window.

Well, in Xcode 5 the modules directory now resides within the derived data folder, which I for obvious reasons didn't delete. I deleted the contents of ~/Library/Developer/Xcode/DerivedData/ModuleCache and the ~/Library/Preferences/com.apple.Xcode.plist and everything then seems to work, after I restarted Xcode.


Examples related to xcode

Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64 iPhone is not available. Please reconnect the device Make a VStack fill the width of the screen in SwiftUI error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Xcode 10: A valid provisioning profile for this executable was not found Xcode 10, Command CodeSign failed with a nonzero exit code

Examples related to caching

Disable nginx cache for JavaScript files How to prevent Browser cache on Angular 2 site? Curl command without using cache Notepad++ cached files location Laravel 5 Clear Views Cache Write-back vs Write-Through caching? Tomcat 8 throwing - org.apache.catalina.webresources.Cache.getResource Unable to add the resource Chrome - ERR_CACHE_MISS How do I use disk caching in Picasso? How to clear gradle cache?

Examples related to xcode4

How to select Multiple images from UIImagePickerController Xcode: failed to get the task for process Adding Image to xCode by dragging it from File The identity used to sign the executable is no longer valid Can't ignore UserInterfaceState.xcuserstate Why can I not switch branches? How to Empty Caches and Clean All Targets Xcode 4 and later Apple Mach-O Linker Error when compiling for device How can I build for release/distribution on the Xcode 4? Xcode 4 - "Archive" is greyed out?

Examples related to xib

Load a UIView from nib in Swift Correct way to load a Nib for a UIView subclass How can I load storyboard programmatically from class? Load view from an external xib file in storyboard How to load a xib file in a UIView How to Empty Caches and Clean All Targets Xcode 4 and later Loaded nib but the 'view' outlet was not set How do you load custom UITableViewCells from Xib files?