我有很多!设备太多无法一一删除,感谢苹果不包括多选。也不要双击删除,否则 Xcode 会崩溃。我找到了一个可以删除重复项的脚本,但是它仅在每种类型只有 1 个重复项时才有效,因此在我的情况下不起作用。因此,我编辑了脚本以简单地删除所有模拟器,然后您只需在“设备”窗口中单击加号即可添加所需的任何模拟器。
将以下内容另存为remove_all_sims.py:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
from subprocess import Popen, PIPE
from subprocess import call
p = Popen(["xcrun","simctl","list","devices"], stdin=PIPE, stdout=PIPE, stderr=PIPE)
output, err = p.communicate(b"input data that is passed to subprocess' stdin")
blocks = re.split("--\s+(.*?)\s+--",output)
dic = {}
i=0
for block in blocks:
matches = re.findall("iOS 8.4",block)
if len(matches)>0:
content = blocks[i+1]
lines = content.split("\n")
for line in lines:
line = line.strip()
if len(line)>0:
match = re.match("(.*?)\(",line)
if match:
devicename = match.group(1)
idMatch = re.match(".*?\((.*?)\).*",line)
dic[devicename] = idMatch.group(1)
call(["xcrun","simctl","delete",idMatch.group(1)])
# print match.group(1)
# print line
i = i+1
for guid in dic.itervalues():
call(["xcrun","simctl","delete",guid])
然后运行:
python remove_all_sims.py
注意它仅适用于 iOS 8.4 模拟器的硬编码。