Duplicate iPhone Simulators Appeared on My Xcode
Asked Answered
G

3

24

A duplicate iPhone simulator just appeared after I deleted ~/Library/Developer/Xcode/CoreSimulator folder

Duplicate iPhone Simulators

How to solve this problem?

I've tried to delete ~/Library/Developer/Xcode folder and ~/Library/Application Support/iPhoneSimulator folder. But all failed.

Gamelan answered 23/12, 2014 at 4:43 Comment(3)
Delete XCode.app and try re-installing.Eldredge
Deleting Xcode.app and everything under ~/Library/Developer still didn't do the trick. @nikita-leonov 's answer was the only thing that did the trick for me.Hairbreadth
possible duplicate of Xcode 6.4 showing duplicate 'Simulators' with Unique IdThornhill
V
55

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.

Voletta answered 7/1, 2015 at 4:21 Comment(4)
Thank you for that! It's amazing to me that I could uninstall Xcode, delete everything under ~/Library/Developer, re-install Xcode, and this would still show up. I generally like to leave my magic system voodoo state on my Windows machines. :PHairbreadth
Works like a magic! At some point I had 3 duplicated simulators for each version :)Keefe
I wish I had known it was this easy a long time ago. Thanks. :)Bloodworth
This works, but for some reason, deleting one takes about 10 seconds. I have about 100 duplicates, any way to speed this up?Dominus
N
32

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.

Nates answered 7/8, 2015 at 6:15 Comment(4)
Me too, Option 1. This saved me a lot of time. :DMarc
reset_simulators deleted also my iOS 7 simulator :-(Knecht
Somehow I ended up with 1380 (!) Simulators on my system, and snapshot reset_simulators worked for me as well. Took a bit to run, but much faster than doing anything manually. :)Lilybel
Fastlane for the win, had no idea snapshot could do such a wonderful thing. Thanks for the 1-liner. :)Chantal
T
5

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.

Many duplicates

Thornhill answered 4/8, 2015 at 23:3 Comment(6)
That didn't have any effect for me, even after emptying the trash, quitting Xcode, and relaunching it.Elainaelaine
sorry about that i have updated my answer with a link to a script to remove all simulators, then you can simply re-create any you need afterwards using the plus button in the Devices window..Thornhill
This worked for me and saved me a lot of time, since I had so many duplicates that it took Xcode a few seconds to re-render the list after deleting each one. Thanks.Fusty
just a note that if you have setup simulators for several versions of iOS, you will need to run the script several times, by changing this line: content = blocks[i+1] and adjusting the index to each version in the blocks in my case, I had to run it 3 times for: <br/> - content = blocks[i+2]<br/> - content = blocks[i+4]<br/> - content = blocks[i+6]<br/> Hopehopeful
if you setup simulators for several versions of iOS, you need to run the script multiple times, each time adapting the content = blocks[i+1] In my case, I had to run it 3 times, using: content = blocks[i+2] content = blocks[i+4] content = blocks[i+6]Hopehopeful
also, if you are like me and have installed several versions of Xcode simultaneously, don't forget to run: sudo xcode-select --switch "/Applications/Xcode 6.4.app" for each version of XCodeHopehopeful

© 2022 - 2024 — McMap. All rights reserved.