Reputation: 65369
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?
Upvotes: 273
Views: 421194
Reputation: 229
Open Terminal -> Enter the following command to clear the Xcode cache:
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode
Upvotes: 0
Reputation: 79
For convenience reasons, I created an apple script for this routine
tell application "Xcode"
activate
set targetProject to active workspace document
repeat 60 times
if loaded of targetProject is true then
exit repeat
end if
delay 0.5
end repeat
stop targetProject
set action to clean targetProject
repeat 60 times
if completed of action is true then
exit repeat
end if
delay 0.5
end repeat
quit
end tell
set cacheDir to do shell script "getconf DARWIN_USER_CACHE_DIR"
set whoAmI to do shell script "whoami"
tell application "Finder"
try
delete folder (cacheDir & "clang/ModuleCache")
end try
try
delete folder (cacheDir & "clang." & whoAmI & "/ModuleCache")
end try
try
delete every item of folder (cacheDir & "org.llvm.clang/ModuleCache")
end try
try
delete every item of folder (cacheDir & "org.llvm.clang." & whoAmI & "/ModuleCache")
end try
try
delete every item of folder ((path to home folder as text) & "Library:Developer:Xcode:DerivedData")
end try
try
delete every item of folder ((path to home folder as text) & "Library:Caches:com.apple.dt.Xcode")
end try
end tell
tell application "Xcode" to activate
Then I exported the script as an application
And now I can just press ⌘+Space and type "Xcode reset" in any case of unusual Xcode behaviour.
I also created a gist here
Upvotes: 0
Reputation: 3467
Simply delete Derived Data from Terminal,
rm -rf ~/Library/Developer/Xcode/DerivedData/*
Upvotes: 4
Reputation: 93
You can use PrettyClean to clean the all of dev tools caches including Xcode.
Steps:
Upvotes: -4
Reputation: 6509
For me with cached images helped: Xcode -> Product -> Clean Build Folder
Upvotes: 0
Reputation: 8609
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:
DerivedData
folder in ~/Library/Developer/Xcode/DerivedDataWhat 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).
Upvotes: 26
Reputation: 2479
My "DerivedData" with Xcode 10.2 and Mojave was here:
MacHD/Users/[MyUser]/Library/Developer/Xcode
Upvotes: 4
Reputation: 3519
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.
Upvotes: 1
Reputation: 183
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.
Upvotes: 0
Reputation: 534872
Command-Option-Shift-K to clean out the build folder. Even better, quit Xcode and clean out ~/Library/Developer/Xcode/DerivedData manually. Remove all its contents because there's a bug where Xcode will run an old version of your project that's in there somewhere. (Xcode 4.2 will show you the Derived Data folder: choose Window > Organizer and switch to the Projects tab. Click the right-arrow to the right of the Derived Data folder name.)
In the simulator, choose iOS Simulator > Reset Content and Settings.
Finally, for completeness, you can delete the contents of /var/folders; some caching happens there too.
WARNING: Deleting /var/folders can cause issues, and you may need to repair or reinstall your operating system after doing so.
EDIT: I have just learned that if you are afraid to grapple with /var/folders/ you can use the following command in the Terminal to delete in a more targeted way:
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
EDIT: For certain Swift-related problems I have found it useful to delete ~/Library/Caches/com.apple.dt.Xcode. You lose a lot when you do this, like your spare copies of the downloaded documentation doc sets, but it can be worth it.
Upvotes: 565
Reputation: 6606
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.
Upvotes: 0
Reputation: 1409
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.
Upvotes: 6
Reputation: 2746
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.
Upvotes: 0
Reputation: 19996
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.
Upvotes: 7
Reputation: 2002
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).
Upvotes: 18
Reputation: 101
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! :)
Upvotes: 10
Reputation: 995
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.
Upvotes: 78