How do I completely remove all Xcode program and cache files?
The problems you talk seem originated by Swift version.
To answer to your question, when you download a new Xcode App (and yes, you can have more than one Xcode app in the same computer) everything is inside the huge app.
All the local data are inside the folder
~/Library/Developer/Xcode/
Where you can find several folders with lot of data. If you have problems with Ide size you could check the "IDEPreferencesController.xcuserstate" that is found inside UserData folder.
How to Empty Caches and Clean All Targets Xcode 4 and later
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.
Which Xcode files can I safely delete?
You can safely delete the Caches (Xcode will rebuild them, which will slow down Xcode in the beginning), the Build Data and Indexes (which Xcode will also restore the next time you open the project/build the project where the data was deleted). From my understanding, iOS Device Support is for connecting your own device to the computer. Xcode will probably restore this as well, I would delete the iOS versions which you don't use. bridgeOS is for devices like the Touch Bar (according to Wikipedia).
How to clean junk files in Xcode from iOS support
- Delete the contents of
"~/Library/Developer/Xcode/iOS DeviceSupport/"
. - Remove all "paired devices" in iOS settings > Developer.
- Connect iPhone to the Mac and pick "Don't trust".
Since the above is not okay for iTunes syncing etc, try the following:
Delete the contents of the folder "~/Library/Developer/Xcode/iOS DeviceSupport/"
and then right click > get info > lock the folder.
Locking the folder will stop Xcode from copying the simulator files from the iPhone to that folder next time you connect them.
- https://apple.stackexchange.com/questions/380024/how-to-stop-xcode-downloading-ios-support-package-of-my-iphone
It is possible that Xcode starts downloading it via nsurlsessiod
so you can block it either
- by using a firewall
- https://apple.stackexchange.com/questions/393689/how-to-stop-catalina-from-contacting-apple-servers-when-executing-programs/393698#393698
- Or by renaming the binary as explained at the link below. (I haven't tried it)
- Xcode simulator constantly download something
How to Delete Derived Data and Clean Project in Xcode 5 and later?
It's basically a two-or-three-step process, which cleans the project of all cached assets.
Of course, if anyone uses this technique, and a project still does not show updated assets, then please add an answer! It’s definitely possible that someone out there has encountered situations that require a step that I’m not including.
- Clean your project with Shift-Cmd-K
- Delete derived data by calling a shell script (details below), defined in your bash profile
- Uninstall the App from the Simulator or device.
- For certain types of assets, you may also have to reset the Simulator (under the iOS Simulator menu)
To call the shell script below, simply enter enter the function name (in this case 'ddd') into your terminal, assuming it's in your bash profile. Once you've saved your bash profile, don't forget to update your terminal's environment if you kept it open, with the source command:source ~/.bash_profile
ddd() {
#Save the starting dir
startingDir=$PWD
#Go to the derivedData
cd ~/Library/Developer/Xcode/DerivedData
#Sometimes, 1 file remains, so loop until no files remain
numRemainingFiles=1
while [ $numRemainingFiles -gt 0 ]; do
#Delete the files, recursively
rm -rf *
#Update file count
numRemainingFiles=`ls | wc -l`
done
echo Done
#Go back to starting dir
cd $startingDir
}
I hope that helps, happy coding!
How can I delete derived data in Xcode 8?
Many different solutions for this problem. Most of them work as well.
Another shortcut seems to be added as well:
Shift + alt + command ⌘ + K
Will ask you to:
Are you sure you want to clean the build folder for “MyProject”?
This will delete all of the products and intermediate files in the build folder.
In most cases this would be enough to solve your problems.
UPDATE
As of Xcode 9 you'll be able to access the Derived Data folder by navigating to
File -> Project Settings
or if you use a Workspace:
File -> Workspace Settings
And press the arrow behind the path:
Completely remove XCode Target
I think you'll have to make a lot of manual work to do that:
- open .xcodeproj with alt-click - Show Package Content
- open project.pbxproj with the text editor
Now look for/* Begin PBXNativeTarget section */
, you'll find the list of the targets below.
Here comes the part which will likely make you create the new project - there're so many cross-references by identifiers to be analyzed. You'll have to find yourself what you want to remove there. - remove xcuserdata to clear users preferences for the project
Related Topics
Enum Named 'Type' in Nested Class Fails
Swift Switch Case Compiler Error
Why Is My Libraries Not Able to Expand on The Cocoapods and Shows as Objective-C Not Swift
What's The Difference Between [String] VS. [(String)]
Get Output Frames Failed, State 8196
Error Loading Media Sources in Mlmedialibrary
Test Enum for Equality in for ... Where Clause
Swiftui: What Are The Differences Between Image and UIimage
Extra Argument Userinfo in Call
Nscollectionview Selection Handling in Swift
Combined Watch Os and iOS Framework
Swift: Parse, Query Date Field Based on Nsdate()
Perform Segue After UIalertcontroller Is Dismissed
Enum for Buttonstyle in Swiftui
Create a Generic Swift Function to Return an Array of Core Data Entities
Emitting a Warning for a Deprecated Swift Protocol Method in Implementing Types
How to Call Completionhandler for Performfetchwithcompletionhandler in Swift