ios Xcode - 免费清除设备文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34910383/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 08:36:31  来源:igfitidea点击:

Xcode - free to clear devices folder?

iosxcodemacosios-simulator

提问by Libor Zapletal

I am deleting some folders and files to make more space on my drive. I know that in path:

我正在删除一些文件夹和文件以在我的驱动器上腾出更多空间。我知道在路径中:

~/Library/Developer/CoreSimulator/Devices/

There are folders for each simulator and each version. This folder has around 11GB size for me. I know that I could delete simulators with old versions that I no longer use. But from that unique identifier I can't know which is the right one and which not. So my question is: Can I delete it all? It's okay if next time I wouldn't have any of my app in simulator but can I loose something more? Old versions of simulator? Or anything else? Thanks

每个模拟器和每个版本都有文件夹。这个文件夹对我来说大约有 11GB 大小。我知道我可以删除不再使用的旧版本模拟器。但是从那个唯一标识符我不知道哪个是正确的,哪个不是。所以我的问题是:我可以全部删除吗?如果下次我在模拟器中没有我的任何应用程序也没关系,但我可以失去更多东西吗?旧版本的模拟器?或者别的什么?谢谢

回答by Aaron

The ~/Library/Developer/CoreSimulator/Devices/path is where Xcode stores most of the data needed for your individual simulator devices.

~/Library/Developer/CoreSimulator/Devices/路径是 Xcode 存储您的单个模拟器设备所需的大部分数据的地方。

Beau Nouvelle's suggestion about deleting downloaded simulator versions would not change the size of these folders, as the runtimes are stored elsewhere.

Beau Nouvelle 关于删除下载的模拟器版本的建议不会改变这些文件夹的大小,因为运行时存储在其他地方。

If you go to the terminal, you can use the simctltool (comes with Xcode 6+) to list all of the actual simulator devices you have, along with the ids so that you can figure out what folders to delete.

如果您转到终端,您可以使用simctl工具(Xcode 6+ 附带)列出您拥有的所有实际模拟器设备以及 ID,以便您可以找出要删除的文件夹。

Note, you'll see me constantly use xcrun simctlin this answer. That adds a bit of abstraction to things by having xcrun go look up the appropriate version of simctl for your currently chosen Xcode. If your system is not as complicated as mine, you can probably get by with dropping the "xcrun" part and the commandline should still find the simctl tool.

请注意,您会看到我在此答案中经常使用xcrun simctl。通过让 xcrun 查找适合您当前选择的 Xcode 的 simctl 版本,这增加了一些抽象。如果您的系统不像我的那么复杂,您可能可以通过删除“xcrun”部分来解决问题,并且命令行仍应找到 simctl 工具。

xcrun simctl list devices

xcrun simctl list devices

Here are some selected snippets of the output I received:

以下是我收到的输出的一些选定片段:

== Devices ==

-- iOS 8.2 --

-- iOS 8.4 --

iPhone 6 Plus (23E36868-715A-48C8-ACC3-A735C1C83383) (Shutdown)

iPad Air (2928379B-70E3-4C59-B5BA-66187DDD3516) (Shutdown)

-- iOS 9.1 --

My Custom iPhone 4s (4F27F577-FFD0-42C1-8680-86BBA7394271) (Shutdown)

iPad Retina (85717B35-313A-4161-850E-D99D5C8194A6) (Shutdown)

-- Unavailable: com.apple.CoreSimulator.SimRuntime.iOS-9-0 --

iPhone 4s (D24C18BC-268C-4F0B-9CD8-8EFFDE6619E3) (Shutdown) (unavailable, runtime profile not found)

== 设备 ==

-- iOS 8.2 --

-- iOS 8.4 --

iPhone 6 Plus (23E36868-715A-48C8-ACC3-A735C1C83383)(关机)

iPad Air (2928379B-70E3-4C59-B5BA-66187DDD3516)(关机)

-- iOS 9.1 --

我的自定义 iPhone 4s (4F27F577-FFD0-42C1-8680-86BBA7394271)(关机)

iPad Retina (85717B35-313A-4161-850E-D99D5C8194A6)(关机)

-- 不可用:com.apple.CoreSimulator.SimRuntime.iOS-9-0 --

iPhone 4s (D24C18BC-268C-4F0B-9CD8-8EFFDE6619E3)(关机)(不可用,未找到运行时配置文件)

From that you can see that I have no iOS 8.2 simulator devices. I have some 9.1 and 8.4 simulator devices. I do have a 9.0 simulator device made (a remnant of my work on Xcode 7.0), but I don't have the 9.0 simulator runtime itself. So that's a good candidate for deletion, or a reminder that I should go download the 9.0 simulator in Xcode.

从中可以看出我没有 iOS 8.2 模拟器设备。我有一些 9.1 和 8.4 模拟器设备。我确实有一个 9.0 模拟器设备(我在 Xcode 7.0 上的工作的残余),但我没有 9.0 模拟器运行时本身。所以这是一个很好的删除候选者,或者提醒我应该去 Xcode 下载 9.0 模拟器。

If you want, you can use those ids to identify the folder for the device in question and delete it manually (in this case I would delete the "D24C18BC-268C-4F0B-9CD8-8EFFDE6619E3" folder), but you can also use the simctl tool to do that.

如果需要,您可以使用这些 ID 来识别相关设备的文件夹并手动删除它(在这种情况下,我将删除“D24C18BC-268C-4F0B-9CD8-8EFFDE6619E3”文件夹),但您也可以使用simctl 工具来做到这一点。

Usage according to the 7.1.1 version of simctl:

根据 simctl 7.1.1 版本使用:

xcrun simctl help delete
Usage: simctl delete <device> [... <device n>] | unavailable

So I can either delete the individual device(s):

所以我可以删除单个设备:

xcrun simctl delete D24C18BC-268C-4F0B-9CD8-8EFFDE6619E3

xcrun simctl delete D24C18BC-268C-4F0B-9CD8-8EFFDE6619E3

or I can bulk delete all of the unavailable ones with:

或者我可以批量删除所有不可用的:

xcrun simctl delete unavailable

xcrun simctl delete unavailable

There is also no need to limit yourself purely to unavailable simulators.

也没有必要将自己局限于不可用的模拟器。

If you need any further help with the tool, it comes with a fairly straight forward help command:

如果您需要该工具的任何进一步帮助,它带有一个相当简单的帮助命令:

xcrun simctl help

xcrun simctl help

回答by Beau Nouvelle

Sometimes Xcode likes to double up on its simulators.

有时 Xcode 喜欢在模拟器上加倍努力。

Usually the fix for me has always been to just delete them all. Deleting them is harmless as you can always download them again later.

通常对我来说,修复方法一直是将它们全部删除。删除它们是无害的,因为您可以随时再次下载它们。

Xcode > Preferences > Downloads

Xcode > 首选项 > 下载

Just remember that if you have any old simulators in there (iOS 8.0-) you won't be able to download them again through Xcode.

请记住,如果您有任何旧模拟器(iOS 8.0-),您将无法通过 Xcode 再次下载它们。

回答by Karthik

I had a similar issue a while back, xcode was taking up 47G on my drive. I tried deleting some Simulator Devices which stopped my xcode from working (crazy). So i deleted everthing related to xcode and installed fresh. Its just my experience.

不久前我遇到了类似的问题,xcode 在我的驱动器上占用了 47G。我尝试删除一些使我的 xcode 停止工作的模拟器设备(疯狂)。所以我删除了与 xcode 相关的所有内容并重新安装。这只是我的经验。

回答by whyoz

in Xcode 8:

在 Xcode 8 中:

1) Run $ sudo du -khd 1in Terminal to see the folder size of each folder;

1)$ sudo du -khd 1在终端中运行,查看每个文件夹的文件夹大小;

2) Run $ cd library/developer/coresimulator/devicesto see the GB stored for all your Xcode simulators;

2) 运行$ cd library/developer/coresimulator/devices以查看为所有 Xcode 模拟器存储的 GB;

3) You'll begin to see where a ton of storage is hiding! Now just navigate to that location on your Macintosh HD and view the devices.plistin each device folder;

3) 您将开始看到大量存储空间的藏身之处!现在只需导航到 Macintosh HD 上的该位置并查看每个设备文件夹中的devices.plist

4) Decide which folders to delete and keep by deleting any simulators/iOS versions you've ran in the past but no longer need for testing. Old sqlite versions that could act as old backups, or other content exists in these folders, so consider that before you delete everything in this folder.

4) 通过删除您过去运行但不再需要测试的任何模拟器/iOS 版本来决定要删除和保留哪些文件夹。可以充当旧备份的旧 SQLite 版本,或这些文件夹中存在其他内容,因此在删除此文件夹中的所有内容之前,请考虑这一点。

I saved over 50GB the first time I did this.

我第一次这样做时节省了超过 50GB。