249

我正在运行最初仅支持 iOS 5.1 的 Xcode 4.3.1 iOS-Simulator。

我需要使用 iOS 4.3 测试我的代码,所以我使用 Xcode 的“安装”功能来安装它,如“使用 iOS 4.3 设备模拟器安装 Xcode?”中所述。

现在我完成了测试,但找不到卸载 4.3 部分(“iPhone 4.3 Simulator”和“iPad 4.3 Simulator”)的方法。我想减少方案菜单中的混乱。

Apple 的 Xcode listserv 上没有人知道答案!

编辑:请注意,自 Xcode 4.3 以来发生了很大变化,因此建议任何阅读本文的人查看所有答案。最新的,如史蒂夫莫泽的可能对你更有用!

编辑 10/2017:由 Julio Carrettoni 在 Twitter 上发布

如果您是 iOS 开发人员,请执行以下操作:
$ xcrun simctl delete unavailable
它会删除 Xcode 不再使用的旧模拟器。对我来说是 6Gb 自己没有尝试过......

[另外,我刚刚看到 Russ Bishop 在下面的评论中提到了这一点......]

4

20 回答 20

218

在 Xcode 6+ 中,您只需转到 Menu > Window > Devices > Simulators 并删除不需要的模拟器。

于 2014-09-23T09:14:35.197 回答
187

October 2020 update

As was mentioned, you can use xcrun to do a few things:

  • xcrun simctl list devices or xcrun simctl list --json to list all simulators
  • xcrun simctl delete <device udid> to delete specific device
  • xcrun simctl delete unavailable to remove old devices for runtimes that are no longer supported

More things you can do with xcrun (see code snippet)

- `xcrun simctl boot <device udid>` to launch (multiple) simulators
- `xcrun simctl io booted recordVideo — type=mp4 ./test.mp4` to record simulator video
- `xcrun simctl io booted screenshot ./screen.png` to make screenshot of simulator
- `xcrun simctl openurl booted https://google.com` to open URL in simulator
- `xcrun simctl addmedia booted ./test.mp4` to upload photo or video file (for photos app)
- `xcrun simctl get_app_container booted <your apps bundle identifier>` to find the app container (where identifier is like *com.bundle.identifier*)
- `xcrun simctl help` to explore **more** commands

Original Answer

September 2017, Xcode 9

Runtimes

You will find them here:

/Library/Developer/CoreSimulator/Profiles/Runtimes

enter image description here

Devices

To delete devices go here:

~/Library/Developer/CoreSimulator/Devices

Much easier to delete them use Xcode: Xcode->Window->Devices and Simulators enter image description here

Helping Xcode "forget" about runtimes and prevent from re-installing them - delete .dmg file(s) here:

~/Library/Caches/com.apple.dt.Xcode/Downloads

I hope it will help someone

于 2017-09-20T06:59:19.157 回答
182

您是否尝试从 Xcode 包中删除 4.3 SDK?

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs

请同时删除相应的.dmg文件

~/Library/Caches/com.apple.dt.Xcode/Downloads

防止 Xcode 再次重新安装相同的包。


对于 XCode >= 6,请参阅@praveen-matanam 的答案

于 2012-05-31T14:06:41.970 回答
168

在 Xcode 6 及更高版本中,您可以从路径中找到并删除模拟器/Library/Developer/CoreSimulator/Profiles/Runtimes。重新启动 Xcode 以使其生效(可能不需要)。

于 2015-05-13T06:04:40.510 回答
86

Run this command in terminal to remove simulators that can't be accessed from the current version of Xcode (8+?) in use on your machine.

xcrun simctl delete unavailable

Also if you're looking to reclaim simulator related space Michael Tsai found that deleting sim logs saved him 30 GB.

~/Library/Logs/CoreSimulator
于 2017-03-09T19:25:24.747 回答
27

如果您只是删除 SDK,Xcode 4.6 将提示您重新安装任何旧版本的 iOS 模拟器。为避免这种情况,您还必须删除 Xcode 缓存。这样您就不会被迫在启动时重新安装旧版 SDK。

要删除 iOS 5.0 模拟器,请删除这些,然后重新启动 Xcode:

  1. /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/PhoneSimulator5.0.sdk
  2. ~/Library/Caches/com.apple.dt.Xcode

例如,在全新安装 Xcode 后,我从 Xcode 首选项安装了 iOS 5.0 模拟器。后来我觉得5.1就够了,但是5.0版本又删不掉了。Xcode 一直强迫我在启动时重新安装它。删除缓存文件和SDK后,不再询问。

于 2013-02-01T22:07:38.637 回答
25

I had the same problem. I was running out of space.

Deleting old device simulators did NOT help.

My space issue was caused by xCode. It kept a copy of every iOS version on my macOS since I had installed xCode.

Delete the iOS version you don't want and free up disk space. I saved 50GB+ of space.

enter image description here



NOTE -> can't you see ~/Library inside Finder? It is hidden by default. Use Terminal and type cd ~/Library/Developer/Xcode/iOS\ DeviceSupport/ or google how to see hidden folders.



NOTE -> if you have multiple users on a single macOS machine, make sure to find the directory ONLY with the user account that originally installed xCode.

于 2017-09-07T10:50:23.437 回答
11

following some of the answers here, deleting some simulators from my Xcode Menu > Window > Devices > Simulators did nothing to help my dying disk space: enter image description here

however, cd ~/Library/Developer/Xcode/iOS\ DeviceSupport and running du -sh * I got all of these guys:

2.9G    10.0.1 (14A403)
1.3G    10.1.1 (14B100)
2.9G    10.3.2 (14F89)
1.3G    10.3.3 (14G60)
1.9G    11.0.1 (15A402)
1.9G    11.0.3 (15A432)
2.0G    11.1.2 (15B202)
2.0G    11.2 (15C114)
2.0G    11.2.1 (15C153)
2.0G    11.2.2 (15C202)
2.0G    11.2.6 (15D100)
2.0G    11.4 (15F79)
2.0G    11.4.1 (15G77)
2.3G    12.0 (16A366)
2.3G    12.0.1 (16A404)
2.3G    12.1 (16B92)

All together that's 33 GB!

A blood bath ensued

see more details here

于 2018-12-18T04:18:11.020 回答
7

Update 2021

We can just use the Storage Management tool: CMD + Space and search storage:

Under Developer: you can find Xcode Cache and build files and also old version of iOS support files that you can delete.

enter image description here

Tested on macOS Big Sur

于 2021-10-18T22:58:36.393 回答
6
于 2015-10-30T05:45:12.163 回答
5

In XCode open Window - Devices, then select and remove the outdated simulators.

于 2017-06-13T14:09:20.657 回答
4

I wrote up one-line bash script that would delete ALL your simulators:

xcrun simctl list devices | grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})" | xargs -L1 xcrun simctl delete
  • xcrun simctl list devices will list all the simulators installed on your machine
  • grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})" will grab the device UUID
  • xargs -L1 xcrun simctl delete will attempt to delete the device for each UUID it found

If you want to see everything it'll execute, you can add echo before xcrun, i.e.

xcrun simctl list devices | grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})" | xargs -L1 echo xcrun simctl delete
于 2019-05-11T00:22:10.160 回答
4

Some people try to fix it using one way, some the second. Basically, there are 2 issues, which if you check them out & solve both - in 99% it should fix this issue:

  1. Old device simulators located at YOUR_MAC_NAME (e.g. Macintosh) -> Users -> YOUR_USERNAME (daniel) -> Library -> Developer -> Xcode -> iOS Device Support. Leave there, the newest one, as of today this is 13.2.3 (17B111), but in future it'll change. The highest number (here 13.2.3) of the iOS version indicates that it's newer.

  2. After this list your devices in Terminal by running xcrun simctl list devices. Many of them might be unavailable, therefore delete them by running xcrun simctl delete unavailable. It'll free some space as well. To be sure that everything is fine check it again by running xcrun simctl list devices. You should see devices only from the newest version (here 13.2.3) like the screenshot below shows.

enter image description here

As a bonus which is slightly less relevant to this question, but still free's some space. Go to YOUR_MAC_NAME (e.g. Macintosh) -> Users -> YOUR_USERNAME (e.g. daniel) -> Library -> Developer -> Xcode -> Archives. You'll see many archived deployed application, most probably you don't need all of them. Try to delete these ones, which are not being used anymore.

Using these 2 methods and the bonus method I was able to get extra 15 GB of space on my Mac.

PS. Simply deleting simulators from Xcode by going to Xcode -> Window -> Devices and Simulators -> Simulators (or simply CMD + SHIFT + 2 when using keyboard shortcut) and deleting it there won't help. You really need to go for the described steps.

于 2019-12-25T15:07:54.023 回答
3

您可以做的另一件事是将部署目标更改为最高值。这将阻止方案菜单显示旧版本。

为此,请转到:Target->Summary,然后更改部署目标。

于 2013-06-24T18:29:51.300 回答
3

I tried all answers. None of them worked for me.

What worked for me on Sierra + Xcode 8.2 was going to:

/Library/Developer/CoreSimulator/Devices and deleting all devices.

(Maybe this won't work for you, maybe this is a solution as a standalone, or maybe you have to do this in addition to other answers, but I did all solutions here and so not sure what did the deed). Just be aware that some of the answers here are old and the location of simulator has changed. Snowcrash's answer seems to be most recent.

于 2017-04-18T15:38:29.600 回答
2

The problem with these answers is that, with every Xcode update, menus and locations will change.

Just go to /Applications/Xcode.app/Contents/Developer/Platforms and delete what you don't need. Xcode will start fine. If you're at all concerned then you can simply restore from Trash.

于 2016-10-09T14:37:07.677 回答
2
  1. Open Xcode --> Go to Window (from menu bar) --> Devices and Simulators --> Click on Simulator --> Right-click on the simulator that you want to delete --> Click Delete

  2. To delete any unwanted simulators that you installed in the past as an extra Component through Xcode.

  • Open Terminal

  • Type open /Library/Developer/CoreSimulator/Profiles/Runtimes

  • Delete undesired simulators

于 2020-10-28T05:13:20.117 回答
1

On Mac, check /Library/Developer/Xcode/iOS\ DeviceSupport

iOS DeviceSupport

于 2020-08-17T21:32:23.087 回答
1

You can use the following snippet to delete unavailable runtimes:

echo "rm -rf $(xcrun simctl list runtimes -j |\
      jq ".runtimes[] | select(.isAvailable|not) | .bundlePath" | xargs)"

to execute, remove echo or add | bash at the end.

If you don't have jq command available, you can get it using brew install jq

于 2020-09-08T14:17:56.507 回答
-2

Command+Space

Type 'simulator'

open the old beta simulator you no longer need.

right-click on it in the dock, then choose Options>'Show in Finder'

Close the app, then remove it from the folder.

:)

于 2017-10-13T03:56:53.753 回答