ios Xcode Simulator:如何删除旧的不需要的设备?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10834817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode Simulator: how to remove older unneeded devices?
提问by David H
I'm running Xcode 4.3.1 iOS-Simulator which originally only supports iOS 5.1.
我正在运行 Xcode 4.3.1 iOS-Simulator,它最初只支持 iOS 5.1。
I need to test my code with iOS 4.3, so I used Xcode's "Install" feature to install it as described in "Installing Xcode with iOS 4.3 device simulator?"
我需要使用 iOS 4.3 测试我的代码,所以我使用 Xcode 的“安装”功能来安装它,如“使用 iOS 4.3 设备模拟器安装 Xcode?”中所述。
Now I'm finished with testing but cannot find a way to uninstall the 4.3 portions ("iPhone 4.3 Simulator" and "iPad 4.3 Simulator"). I want to reduce the clutter in the Scheme menu.
现在我完成了测试,但找不到卸载 4.3 部分(“iPhone 4.3 模拟器”和“iPad 4.3 模拟器”)的方法。我想减少方案菜单中的混乱。
No one on Apple's Xcode listserv knew the answer!
Apple 的 Xcode 列表服务器上没有人知道答案!
EDIT: note that much has changed since Xcode 4.3, so suggest anyone reading this look at all the answers. The newest ones such as Steve Moser's may be of more use to you!
编辑:请注意,自 Xcode 4.3 以来发生了很大变化,因此建议任何阅读本文的人查看所有答案。Steve Moser 等最新的可能对您更有用!
EDIT 10/2017: Posted on Twitter by Julio Carrettoni?
编辑 10/2017:由 Julio Carrettoni 在 Twitter 上发布?
If you are an iOS developer, execute this:
$ xcrun simctl delete unavailable
It removes old simulators Xcode no longer use. For me it was 6Gb Did not try it myself...
如果您是 iOS 开发人员,请执行以下操作:
$ xcrun simctl delete unavailable
它会删除 Xcode 不再使用的旧模拟器。对我来说是 6Gb 自己没有尝试过...
[Also, I just saw Russ Bishop mentioned this in a comment below already...]
[另外,我刚刚看到 Russ Bishop 在下面的评论中提到了这一点......]
采纳答案by childno?.de
Did you tried to just delete the 4.3 SDK from within the Xcode Package?
您是否尝试从 Xcode 包中删除 4.3 SDK?
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs
please also delete the corresponding .dmg file in
也请删除相应的.dmg文件
~/Library/Caches/com.apple.dt.Xcode/Downloads
~/Library/Caches/com.apple.dt.Xcode/Downloads
to prevent Xcode from re-installingthe same package again.
以防止 Xcode 再次重新安装相同的包。
for XCode >= 6 see @praveen-matanam 's answer
对于 XCode >= 6 见@praveen-matanam 的回答
回答by tomi44g
In Xcode 6+ you can simply go to Menu > Window > Devices > Simulators and delete a simulator you don't need.
在 Xcode 6+ 中,您只需转到 Menu > Window > Devices > Simulators 并删除不需要的模拟器。
回答by Praveen Matanam
In Xcode 6 and above, you can find and delete the simulators from the path /Library/Developer/CoreSimulator/Profiles/Runtimes
. Restart Xcode in order to take effect (may not be needed).
在 Xcode 6 及更高版本中,您可以从路径中找到并删除模拟器/Library/Developer/CoreSimulator/Profiles/Runtimes
。重启 Xcode 才能生效(可能不需要)。
回答by Pavel Kovalev
October 2018 update
2018 年 10 月更新
As was mentioned, you can use xcrun
to do a few things:
如前所述,您可以xcrun
用来做一些事情:
xcrun simctl list devices
orxcrun simctl list --json
to list all simulatorsxcrun simctl delete <device udid>
to delete specific devicexcrun simctl delete unavailable
to remove old devices for runtimes that are no longer supported
xcrun simctl list devices
或xcrun simctl list --json
列出所有模拟器xcrun simctl delete <device udid>
删除特定设备xcrun simctl delete unavailable
删除不再支持的运行时的旧设备
More things you can do with xcrun
(see code snippet)
你可以做的更多事情xcrun
(见代码片段)
- `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
2017 年 9 月,Xcode 9
Runtimes
运行时
You will find them here:
你会在这里找到它们:
/Library/Developer/CoreSimulator/Profiles/Runtimes
Devices
设备
To delete devices go here:
要删除设备,请访问:
~/Library/Developer/CoreSimulator/Devices
Much easier to delete them use Xcode:
Xcode->Window->Devices and Simulators
使用 Xcode 更容易删除它们:Xcode->Window->Devices and Simulators
Helping Xcode "forget" about runtimes and prevent from re-installing them - delete .dmg file(s) here:
帮助 Xcode“忘记”运行时并防止重新安装它们 - 在此处删除 .dmg 文件:
~/Library/Caches/com.apple.dt.Xcode/Downloads
I hope it will help someone
我希望它会帮助某人
回答by Steve Moser
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.
在终端中运行此命令以删除无法从您机器上使用的当前版本的 Xcode (8+?) 访问的模拟器。
xcrun simctl delete unavailable
xcrun simctl delete unavailable
Also if you're looking to reclaim simulator related space Michael Tsaifound that deleting sim logs saved him 30 GB.
另外,如果您想回收模拟器相关的空间,Michael Tsai发现删除 sim 日志为他节省了 30 GB。
~/Library/Logs/CoreSimulator
回答by Dan Reese
Xcode 4.6 will prompt you to reinstall any older versions of the iOS Simulator if you just delete the SDK. To avoid that, you must also delete the Xcode cache. Then you won't be forced to reinstall the older SDK on launch.
如果您只是删除 SDK,Xcode 4.6 将提示您重新安装任何旧版本的 iOS 模拟器。为避免这种情况,您还必须删除 Xcode 缓存。这样您就不会在启动时被迫重新安装旧版 SDK。
To remove the iOS 5.0 simulator, delete these and then restart Xcode:
要删除 iOS 5.0 模拟器,请删除这些,然后重新启动 Xcode:
- /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/PhoneSimulator5.0.sdk
- ~/Library/Caches/com.apple.dt.Xcode
- /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/PhoneSimulator5.0.sdk
- ~/Library/Caches/com.apple.dt.Xcode
For example, after doing a clean install of Xcode, I installed the iOS 5.0 simulator from Xcode preferences. Later, I decided that 5.1 was enough but couldn't remove the 5.0 version. Xcode kept forcing me to reinstall it on launch. After removing both the cache file and the SDK, it no longer asked.
例如,在全新安装 Xcode 后,我从 Xcode 首选项安装了 iOS 5.0 模拟器。后来我觉得5.1就够了,但是不能去掉5.0版本。Xcode 一直强迫我在启动时重新安装它。删除缓存文件和 SDK 后,它不再询问。
回答by rustyMagnet
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.
我的空间问题是由 xCode 引起的。自从我安装了 xCode 以来,它在我的 macOS 上保留了每个 iOS 版本的副本。
Delete the iOS version you don't want and free up disk space. I saved 50GB+ of space.
删除不需要的 iOS 版本并释放磁盘空间。我节省了 50GB+ 的空间。
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.
回答by abbood
following some of the answers here, deleting some simulators from my Xcode Menu > Window > Devices > Simulators did nothing to help my dying disk space:
按照这里的一些答案,从我的 Xcode 菜单 > 窗口 > 设备 > 模拟器中删除一些模拟器对我垂死的磁盘空间没有任何帮助:
however, cd ~/Library/Developer/Xcode/iOS\ DeviceSupport
and running du -sh *
I got all of these guys:
然而,cd ~/Library/Developer/Xcode/iOS\ DeviceSupport
运行du -sh *
我得到了所有这些人:
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!
总共是 33 GB!
A blood bath ensued
一场血浴随之而来
see more details here
在此处查看更多详细信息
回答by Raymond
In addition to @childno.de answer, your Mac directory
除了@childno.de 的回答,你的 Mac 目录
/private/var/db/receipts/
/private/var/db/receipts/
may still contains obsolete iPhoneSimulatorSDK .bom
and .plist
files like this:
可能仍包含过时的 iPhoneSimulatorSDK.bom
和如下.plist
文件:
/private/var/db/receipts/com.apple.pkg.iPhoneSimulatorSDK8_4.bom
/private/var/db/receipts/com.apple.pkg.iPhoneSimulatorSDK8_4.plist
/private/var/db/receipts/com.apple.pkg.iPhoneSimulatorSDK8_4.bom
/private/var/db/receipts/com.apple.pkg.iPhoneSimulatorSDK8_4.plist
These could make your Downloads tab of Xcode's preferences show a tick (√
) for that obsolete simulator version.
这些可能会使您的 Xcode 首选项的“下载”选项卡显示√
该过时模拟器版本的勾号 ( )。
To purge the unwanted simulators, you can do a search using this bash command from your Mac terminal:
要清除不需要的模拟器,您可以从 Mac 终端使用此 bash 命令进行搜索:
sudo find / -name "*PhoneSimulator*"
sudo find / -name "*PhoneSimulator*"
Then go to corresponding directories to manually delete unwanted SimulatorSDKs
然后到对应目录手动删除不需要的SimulatorSDKs
回答by catanore
In XCode open Window - Devices, then select and remove the outdated simulators.
在 XCode 中打开 Window - Devices,然后选择并删除过时的模拟器。