Xcode 7.3 taking too much space [duplicate] - xcode

After going through and cleaning my disk with old things that I didn't need anymore, I came across the iOS DeviceSupport folder in ~/Library/Developer/Xcode which was taking nearly 20 GB.
A similar question has been asked before, but since then many things have changed and I would like an up-to-date answer.
As long as I have the version I use for testing, can I delete the older/unused versions without breaking anything?

The ~/Library/Developer/Xcode/iOS DeviceSupport folder is basically only needed to symbolicate crash logs.
You could completely purge the entire folder. Of course the next time you connect one of your devices, Xcode would redownload the symbol data from the device.
I clean out that folder once a year or so by deleting folders for versions of iOS I no longer support or expect to ever have to symbolicate a crash log for.

More Suggestive answer supporting rmaddy's answer as our primary purpose is to delete unnecessary file and folder:
Delete this folder after every few days interval. Most of the time, it occupy huge space!
~/Library/Developer/Xcode/DerivedData
All your targets are kept in the archived form in Archives folder. Before you decide to delete contents of this folder, here is a warning - if you want to be able to debug deployed versions of your App, you shouldn’t delete the archives. Xcode will manage of archives and creates new file when new build is archived.
~/Library/Developer/Xcode/Archives
iOS Device Support folder creates a subfolder with the device version as an identifier when you attach the device. Most of the time it’s just old stuff. Keep the latest version and rest of them can be deleted (if you don’t have an app that runs on 5.1.1, there’s no reason to keep the 5.1.1 directory/directories). If you really don't need these, delete. But we should keep a few although we test app from device mostly.
~/Library/Developer/Xcode/iOS DeviceSupport
Core Simulator folder is familiar for many Xcode users. It’s simulator’s territory; that's where it stores app data. It’s obvious that you can toss the older version simulator folder/folders if you no longer support your apps for those versions. As it is user data, no big issue if you delete it completely but it’s safer to use ‘Reset Content and Settings’ option from the menu to delete all of your app data in a Simulator.
~/Library/Developer/CoreSimulator
(Here's a handy shell command for step 5: xcrun simctl delete unavailable )
Caches are always safe to delete since they will be recreated as necessary. This isn’t a directory; it’s a file of kind Xcode Project. Delete away!
~/Library/Caches/com.apple.dt.Xcode
Additionally, Apple iOS device automatically syncs specific files and settings to your Mac every time they are connected to your Mac machine. To be on safe side, it’s wise to use Devices pane of iTunes preferences to delete older backups; you should be retaining your most recent back-ups off course.
~/Library/Application Support/MobileSync/Backup
Source: https://ajithrnayak.com/post/95441624221/xcode-users-can-free-up-space-on-your-mac
I got back about 40GB!

I wrote a small command-line utility based on the great answer by #JamshedAlam for those who are tired of deleting the contents of those folders manually. Check it out here if you think it would help you.

Yes, you can delete data from iOS device support by the symbols of the operating system, one for each version for each architecture. It's used for debugging.
If you don't need to support those devices any more, you can delete the directory without ill effect

Related

I lost an Xcode Project

Is there any way I can recover a deleted Xcode Project? One night I was making updates and the next morning the whole project was gone. Couldn't find it in the recycling bin or anywhere. The project was synced in my iCloud drive.
The app still runs in the simulator. Is this a good sign? Thanks for any help!
AFAIK, you can't.
Well, if it was sync to iCloud drive, then you can get it back from iCloud (I think so, since I never use that feature to backup). The app in your simulator doesn't help, since the code there was already compiled to machine code and unable to extract back to your original code.
Next time, make sure you have backup methods, like using source control (git, svn...) or zip and clone to drive. Good luck. Sorry for your lost, I know that feeling.

Can Xcode SDKs (such as watchOS and tvOS) be uninstalled?

I have installed Xcode in my machine in order to use it for desktop development (OS X/Cocoa/Command line tools). Whenever I create a new project, there are templates in the wizard for iOS, watchOS and tvOS development, but at this moment I have no interest in these SDKs.
Since Xcode.app is taking a lot of space in my disk even after a fresh install, is it possible to remove these SDKs and reclaim some space?
I found out how to do this. I don't know at this moment if this can have any side-effect on other components for Xcode that could fail. In that case it may be possible to reinstall it from the Mac AppStore again.
Xcode packages the SDKs for these different products as Platforms. There is a Platform for macOS, a Platform for iOS, and so on. All these Platforms are stored in this folder:
/Applications/Xcode.app/Contents/Developer/Platforms
It seems it's possible to actually remove platforms by deleting the correspondent folders inside, such as:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform
Whenever one or more of these folders are deleted, the New Project wizard won't even show them anymore as categories.
Above in incorrect. You will have to reinstall Xcode if you delete any of these folders. /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform I deleted above Xcode wanted me to reinstall.
Try to delete all folders besides "developer" inside platform folders.
Example, delete all beside this:
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/developer.
Other folders in that area you can delete

What can I delete from ~/Library/Developer/Xcode folder?

My ~/Library/Developer/Xcode folder is over 17 gigs in size. As I work in virtual machine (Parallels 12) with a 64 gig limit in total virtual disk size, I need to recover some disk space.
Amongst the folders such as:
Archives
DerivedData
Installs
iOS Device Logs
iOS DeviceSupport
Snapshots
UserData
What might I be able to delete without ruining my project?
Under Archives you can delete anything you want but you should keep recent builds. And you should backup older builds you might need to access in the future.
You can delete everything under DerivedData. Next time you build a project, the needed files will be recreated.
My Installs folder only contains a set of empty folders and the newest if over 3 years old. Check yours, that may be safe to delete.
The iOS Device Logs folder contains old device logs for various versions of iOS. You can safely delete any of the older logs.
The iOS DeviceSupport folder contains a folder for each version of iOS you ever had on an iOS device you ever connected while Xcode was running. Feel free to delete any folders for versions of iOS you don't support anymore. For example, if none of your apps have a Deployment Target older than iOS 8.1, for example, you can safely delete any folder for iOS 8.0.x and earlier. These folders are only needed to symbolicate crash reports.
The Snapshots folder is used by Xcode to save snapshots (backups). You can delete snapshots for old projects you don't care about.
I'd leave the UserData folder alone.
Here is explantation for each folder and what you can delete to reduce the size.
DeviceSupport - You can keep the simulator which log's you may need in future. It's symbolicate crash logs for different device/iOS.
Delete this folder after every few days interval. Most of the time, it occupy huge space!
~/Library/Developer/Xcode/DerivedData
All your targets are kept in the archived form in Archives folder. Before you decide to delete contents of this folder, here is a warning - if you want to be able to debug deployed versions of your App, you shouldn’t delete the archives. Xcode will manage of archives and creates new file when new build is archived.
~/Library/Developer/Xcode/Archives
iOS Device Support folder creates a subfolder with the device version as an identifier when you attach the device. Most of the time it’s just old stuff. Keep the latest version and rest of them can be deleted (if you don’t have an app that runs on 5.1.1, there’s no reason to keep the 5.1.1 directory/directories). If you really don't need these, delete. But we should keep a few although we test app from device mostly.
~/Library/Developer/Xcode/iOS DeviceSupport
Core Simulator folder is familiar for many Xcode users. It’s simulator’s territory; that's where it stores app data. It’s obvious that you can toss the older version simulator folder/folders if you no longer support your apps for those versions. As it is user data, no big issue if you delete it completely but it’s safer to use ‘Reset Content and Settings’ option from the menu to delete all of your app data in a Simulator.
~/Library/Developer/CoreSimulator
(Here's a handy shell command for step 5: xcrun simctl delete unavailable)
Caches are always safe to delete since they will be recreated as necessary. This isn’t a directory; it’s a file of kind Xcode Project. Delete away!
~/Library/Caches/com.apple.dt.Xcode

Prevent Xcode from keeping an old version of a project folder that I want to rename

I'm using Xcode Version 6.4 (6E35b)on a mid 2013 MacBook Air running OS X 10.10.5.
A few days ago, with my code in something of a tangle, Xcode crashed. After the crash, my app built and ran, but didn't do anything except eat memory at a fantastically fast rate.
I keep a git repository and every now and then a put a copy of the whole project folder on an offsite location.
I got one of my older versions out of storage, did a build and run and the same thing happened.
All copies of the same project (by name) now do the same thing. Run, eat memory, and nothing else.
I tried removing DerivedData, removing contents of /var/folders/, removing and replacing schema (in schema -> manage), removing all projects, emptying trash, and have removed Xcode (using "trash me") and reinstalling. No joy. Still the same thing.
I was wanting to change the name of the project anyhow, so I changed the name, and it works. Unfortunately, I can't seem to change the name of the folder containing the project. Using the file inspector, I'm able to change the names of almost everything, but info.plist wants to keep an extra copy of the old project folder name in it's path, as far as DerivedData and LLVM are concerned.
Right now I will continue working with the old project folder name, but new project name.
How do I make Xcode forget the old folder name?
As edited by John Caswell, the answer is basically covered by a careful reading of Duplicate and rename Xcode project & associated folders. I'm going to close this and resubmit the parts of the question that aren't answered.

Can I remove previous versions of iphone support in DeviceSupport folder in Xcode 4?

In my quest to find out why Xcode is so big, i found out that a lot of the space is taken up by the subfolders to the Developer>Platforms>iPhoneOS.platform>DeviceSupport folder..
Since I am (apparently) only allowed to develop for the last of them in Xcode, can I safely remove the rest (in this case 3.0 to 4.2.1)?
Same question regarding the subfolders of Developer>Platforms>iPhoneSimulator.platform>Developer>SDKs..
Yes you can remove SKDs prior to 4.0 in Developer/Platforms/iPhoneOS.platform/DeviceSupport it's just old stuff.
For the subfolders in Developer/Platforms/iPhoneSimulator.platform/Developer it's all the devices version that you will find in iOS Simulator in the menu Hardware>Device>Version. It can be sometimes usefull to keep them to test retrocompatibility (But remember that a test on a real device is still better). But if you want you can also remove these SKDs.

Resources