Duplicate iPhone Simulators Appeared on My Xcode

人盡茶涼 提交于 2019-11-30 00:05:25

It may happen because of multiple Xcode installed or during Xcode upgrades. The only thing that need to be done is to open Xcode -> Window -> Devices select duplicated device and delete it.

I have a same issue after installing Xcode beta version. I found that there are several solution to fix this issue.

1. snapshot

https://github.com/fastlane/fastlane/tree/master/snapshot

usage : gem install fastlane; fastlane snapshot reset_simulators

I solved my problem with this library and it is very simple to use.

2. Xcode->Window->Devices

You can check installed simulators and delete them. But it will take too long time if you have many simulators.

3. xcrun simctl delete

you can use xcrun command in terminal. But you need to input a specific device name with command.

malhal

I had kinda a lot! Too many to delete one by one in Devices, thanks Apple for not including multi-select. Don't double tap delete either or you'll crash Xcode. I found a script that could delete duplicates however it only worked if there was only 1 duplicate of each type so didn't work in my case. I therefor edited the script to simply delete all the simulators, and then you can add any you need just by clicking plus in the Devices window.

Save the following as 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])

Then run:

python remove_all_sims.py

Note its hard coded for iOS 8.4 simulators only.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!