120

I found that Xcode on my laptop consumes much of its storage, so I am trying to delete unnecessary files in Xcode.

There are four directories under Application/Xcode.app/Contents/Developer/Platforms/. I feel that WatchSimulator.platform and AppleTVSimulator.platform are not necessary, because I use Xcode almost only for basic iOS development.

I would like to know if I can delete those platforms directories directly?

Directories

8
  • 1
    Just an FYI... You're only going to gain about half the space shown, as they appear to be compressed. Look at the Get Info sheet, e.g. on my system for WatchOS.platform it shows 50,579,830 bytes (28.2 MB on disk) for 2,212 items and AppleTVSimulator.platform shows 1,865,477,227 bytes (1.1 GB on disk) for 29,705 items. So you're not going to gain as much free space as the values shown in your OP. Nov 22, 2017 at 14:26
  • 1
    The files are compressed and Apples's HFS+ File System supports Transparent Compression but Finder and ls in Terminal lacks a flag to see a file is using hfsCompression, sans the Get Info Sheet where you can see the on disk value is dramatically different then the size show in bytes. There is a utility written by a third party, which includes the source code if one wants to compile it themselves, afsctool. Among its capabilities is to get information about existing HFS+ compressed file(s). Nov 22, 2017 at 15:26
  • What program is helping you determine these large files on your drive?
    – Pysis
    Nov 22, 2017 at 19:57
  • 1
    @Pysis Looks like OmniDiskSweeper to me. That tool hasn't been updated for APFS and compression, though it looks like they have some new test builds out now. Nov 22, 2017 at 22:54
  • 1
    @Zach Lipton, If the OP is running High Sierra and APFS then the files may not compressed because APFS does not yet support compression. Or did this change in 10.13.1? Nov 22, 2017 at 23:36

10 Answers 10

105

Yes, you can delete any simulator that you don't use. I do this routinely when I stop supporting older iOS versions.

If you delete them and then you find that you need them at some point in the future, you can redownload them from Apple's developer site.

The best way to delete them is in Xcode. Go to Window -> Devices and Simulators. This will open a new window with all the devices you use in Xcode.

At the top, tap on Simulators and you'll see a list on the left-side.

From there, find the simulator you want to delete and Cntl - click (or right-click) and select Delete.

I do this with each simulator that runs in each iOS version that I no longer support.

Update July 2020: There's a free utility in the Mac App Store named DevCleaner for Xcode. This application can display and delete simulators and various caches. I've found it be a very quick and easy way to regain space. I'm not the developer or associated with this application in any way.

2
  • 32
    I know this post is a couple years old, but this doesn't appear to remove the simulator, but rather just the listing of it in Xcode. So if one needed to remove it to save disk space, this is not the correct method. Jul 7, 2019 at 23:05
  • Presumably, Sean is referring to deletions made within Xcode, not with DevCleaner... I'm finding ~/Library/Developer/CoreSimulator/Devices/ contains 47GB (12 to 16GB on disk, per du and File Pane. And I'm not finding DevCleaner useful - it knows nothing about them. (None of the free space it said it would free up has been freed up, but realized that's because of Disk Drill data protection and me using df to see free space instead of Finder.) Jun 8 at 7:23
79

Xcode now shares the simulators with all users. So, you need to remove the simulators from the following folder:

/Library/Developer/CoreSimulator/Profiles/Runtimes

For example:

cd /Library/Developer/CoreSimulator/Profiles/Runtimes
sudo rm -rf iOS\ 8.4.simruntime/
sudo rm -rf iOS\ 9.3.simruntime/

Cheers!

2
  • 5
    strangely there are 12.0 and 13.4 runtimes in there but no 14.x runtimes. Where did they go in xcode 12???? Dec 3, 2020 at 12:59
  • thanks, it work pretty good for me :)
    – Hunt3rDe
    Jun 6, 2021 at 13:46
77

You can easily remove all unavailable simulators with this command in the terminal:

xcrun simctl delete unavailable
5
  • 3
    In reality, this doesn't do much. If you run xcrun simctl list you will see that only ~10% of devices are considered "unavailable". Also devices aren't the real space hogs here. iOS runtimes are. @Francois's answer is much better in practice. Sep 13, 2019 at 19:31
  • 3
    @joshuakcockrell Not necessarily; after years of accumulating outdated simulator versions, this freed a ridiculous amount of space in my case. So I guess ymmv. Oct 8, 2019 at 1:02
  • 2
    I counted (wc -l) 148 lines in the list with 'unavailable` and 128 out. The delete command above gave me 14GB back
    – Craig
    Dec 2, 2019 at 23:41
  • if you have Xcode and Xcode-beta xcrun simctl <cmd> will list all beta devices as unavailable, so be careful with blanket deletes
    – J W
    Dec 19, 2020 at 9:46
  • Wow! Thanks! It gave me 25Gb back :)
    – surfrider
    Feb 2, 2021 at 12:38
32

Where Xcode stores simulators in 2019+ Catalina, Xcode 11.0

Runtimes

$ open /Library/Developer/CoreSimulator/Profiles/Runtimes

For example: iOS 13.0, watchOS 6.0 These take the most space, by far. Each one can be up to ~5GB

Devices

$ open ~/Library/Developer/CoreSimulator/Devices

For example: iPhone Xr, iPhone 11 Pro Max. These are typically <15 mb each.

Explanation

Simulators are split between runtimes and devices. If you run $ xcrun simctl list you can see an overview, but if you want to find the physical location of these simulators, look in these directories I've shown.

It's totally safe to delete runtimes you don't support. You can reinstall these later if you want.

4
  • 2
    Thank you, this helped me a lot!
    – acido
    Oct 9, 2019 at 19:49
  • I deleted Runtime folders for the platforms I wasn't using and now Xcode doesn't open anymore.
    – Roberto
    May 13, 2020 at 0:31
  • @Roberto Is there an error or something you are seeing? Can you explain what's happening? Deleting the "iOS 13.3.simruntime" files is totally fine. Just reinstalling Xcode would probably be faster than trying to fix a troubled install. May 13, 2020 at 17:04
  • I reinstalled it, the error was about an image required by a library not being found.
    – Roberto
    May 14, 2020 at 3:22
23

Despite @fsb's answer allows to delete simulator "instances" the right way to free a massive space used by old simulator platforms not needed anymore is going to the following folder:

~/Library/Developer/Xcode/iOS DeviceSupport

and remove the folders corresponding to the simulator/platforms you don't need anymore.

Additionally, there is a very good article including this and other tips:

3
  • 4
    it seems that /Library/Developer/Xcode has been removed after the new macOS update. I can't find it anywhere.
    – Suhaib
    Jul 1, 2018 at 19:36
  • 2
    @Suhaib you forgot the initial tilde "~" which makes the path start on your home directory. The right directory is: ~/Library/Developer/Xcode/iOS DeviceSupport. Sep 17, 2018 at 23:41
  • 2
    don't forget ~/Library/Developer/Xcode/watchOS DeviceSupport too
    – Ryan
    Feb 9, 2020 at 22:54
13
  • to list all simulators xcrun simctl list devices or xcrun simctl list --json

  • to delete specific device xcrun simctl delete <device udid>

  • to remove old devices for runtimes that are no longer supported xcrun simctl delete unavailable

2
  • 2
    you can use xcrun simctl delete all I suppose
    – revau.lt
    Oct 25, 2019 at 12:35
  • 1
    thanks for the old, unsupported bit. I was running out of storage because of the old runtimes.
    – IBG
    Mar 25, 2020 at 0:38
3

To delete simulators by iOS version:

If you only want to remove simulators for a specific version, and you happen to have fastlane installed, you can launch an interactive ruby shell and run the following commands to remove all iOS 10 simulators:

# launch the interactive ruby shell (irb)
$ irb

# require the device manager capabilities of fastlane core
irb(main):001:0> require 'fastlane_core/device_manager'

# delete all iOS 10 simulators
irb(main):002:0> FastlaneCore::Simulator.delete_all_by_version(os_version: "10.0")
2

Open Terminal.app and run the following:

cd /Library/Developer/CoreSimulator/Profiles/Runtimes

Now type the iOS version for which you want to remove simulators in below command, for e.g., if you want to remove for iOS 12.0, run:

sudo rm -rf iOS\ 12.0.simruntime/

2

Run below command in order to remove unsupported simulators. It will empty lot of space

xcrun simctl delete unavailable
0

Beside the regular simulator devices in the known location (~/Library/Developer/CoreSimulator/Devices/), Xcode now creates automatically simulator devices "behind your back" for SwiftUI previews, Interface Builder, Playgrounds and Parallel Testing. They also might take up some space after a while.

So it might be useful to delete them all using the commands below:

xcrun simctl --set playgrounds delete all
xcrun simctl --set previews delete all
xcrun simctl --set interfacebuilder delete all
xcrun simctl --set testing delete all

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .