KISS

Keep It Simple Stupid

Bulk removing iOS Simulators

| comments

Xcode is so helpful that it installs the whole bunch of iOS Simulators when you first launch it, even if you already had a previous version of Xcode. The project I’m working on runs only on iPads, so all the other simulators are unnecessary and can be removed to free up some space.

Removing them manually by going to Window > Devices and Simulators (Cmd+Shift+2) is slow and annoying. Even when you’ve selected one, pressed Delete and confirmed the action, the focus in the list will jump to the top, so you then have to first navigate to the previous position.

Here’s a small tip to make this process much faster.

We’ll be using the simctl utility. To check the installed simulators:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
$ xcrun simctl list devices
== Devices ==
-- iOS 12.4 --
    iPhone 5s (7A9FF159-7579-4C94-90EB-28DE1A9BDC78) (Shutdown)
    iPhone 6 (946CF9E9-217B-4FD8-B30A-C514879828F5) (Shutdown)
    iPhone 6 Plus (3176D5DE-CDF8-404A-96B1-481531134393) (Shutdown)
    iPhone 6s (28A4438C-76A0-4F5A-ADFA-306034AAF370) (Shutdown)
    iPhone 6s Plus (634FBB91-DC4D-451F-A609-DCCF8B067497) (Shutdown)
    iPhone 7 (C3560CBC-772B-4339-A924-2FD7FB0690D4) (Shutdown)
    iPhone 7 Plus (A1A0EA9E-D005-4379-8345-5131E142659C) (Shutdown)
    iPhone 8 (0200021B-228A-496F-942C-3119EADC8803) (Shutdown)
    iPhone 8 Plus (421D63C8-034B-41E2-B9EB-2AAB133320FD) (Shutdown)
    iPhone SE (AB1B5A3E-B92A-4241-9BF1-890AAA9566D5) (Shutdown)
    iPhone X (A28505B6-0444-43ED-BB87-4064A1B1A237) (Shutdown)
    iPhone Xs (D40EB8C5-40C1-4587-BF35-E32451599F28) (Shutdown)
    iPhone Xs Max (1EB566B6-5970-4312-B45C-324814641B08) (Shutdown)
    iPhone Xʀ (8F333A15-47D8-452B-806E-4F2332BBB301) (Shutdown)
    iPad Air (3rd generation) (245CAA9F-7130-49F2-9CC0-60995A73DB69) (Shutdown)
    iPad Air (8F1D143B-35C2-46D0-B4E6-5B9025F41515) (Shutdown)
    iPad Air 2 (A219F858-5712-467F-A164-37A973483CC7) (Shutdown)
    iPad (5th generation) (6D8E17AD-08FD-4B91-B255-0B9B195775C8) (Shutdown)
    iPad Pro (9.7-inch) (A094F81B-74B1-485F-92C9-8B2FD2E1AD3E) (Shutdown)
    iPad Pro (12.9-inch) (4248B87E-17B0-4947-BC75-62B288B54340) (Shutdown)
    iPad Pro (12.9-inch) (2nd generation) (0B07A6FF-1701-4DF3-B952-F15606365702) (Shutdown)
    iPad Pro (10.5-inch) (619EEF68-C205-421E-A8FF-BD7E94D41F10) (Shutdown)
    iPad (6th generation) (33CCB6E5-C6F1-4F93-A5EB-B18F79C92269) (Shutdown)
    iPad Pro (11-inch) (9441B5F2-65C4-4AD9-BF59-D1EDBA6FA6AE) (Shutdown)
    iPad Pro (12.9-inch) (3rd generation) (39363B4E-E743-42C9-86EA-F8BDCFB51175) (Shutdown)
-- tvOS 12.4 --
    Apple TV (69F51E6E-AF2E-4D3C-8F82-A4C4B6CA0833) (Shutdown)
    Apple TV 4K (7DE7371C-4901-4A0E-A62F-DF37D0988996) (Shutdown)
    Apple TV 4K (at 1080p) (15981DE8-984F-43C5-9608-011A38D90395) (Shutdown)
-- watchOS 5.3 --
    Apple Watch Series 2 - 38mm (C6560740-AF1E-4E70-8DBF-C2D0F9BAFFC6) (Shutdown)
    Apple Watch Series 2 - 42mm (BF13C77E-C501-4ACE-B0B3-A79A894BD331) (Shutdown)
    Apple Watch Series 3 - 38mm (6F5F4EA1-DF56-461A-BB7C-48A9E6DABD8B) (Shutdown)
    Apple Watch Series 3 - 42mm (83F66D84-DDE6-4BE2-9A4A-721AA21E18D6) (Shutdown)
    Apple Watch Series 4 - 40mm (9AD7CB82-694F-4224-B591-9AD11067D562) (Shutdown)
    Apple Watch Series 4 - 44mm (9E46495C-FBE6-4EF4-A941-A9DE2922CEE0) (Shutdown)

Lots of unnecessary stuff here, everything but iPad. The simctl list command can output the data in JSON, so it’s easy to filter them with jq:

1
$ xcrun simctl list -j devices | jq '.["devices"][][] | select(.name | contains("iPad") | not) | .udid' | xargs -n1 xcrun simctl delete

The filter .["devices"][][] | select(.name | contains("iPad") | not) | .udid will select the identifiers (udids) of the simulated devices where the name doesn’t contain iPad. Then we pipe the list of identifiers through xargs, where -n1 will run xcrun simctl delete for each one of those because the delete subcommand can’t accept a list of UDIDs.

Verifying what we have done:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ xcrun simctl list devices
== Devices ==
-- iOS 12.4 --
    iPad Air (3rd generation) (245CAA9F-7130-49F2-9CC0-60995A73DB69) (Shutdown)
    iPad Air (8F1D143B-35C2-46D0-B4E6-5B9025F41515) (Shutdown)
    iPad Air 2 (A219F858-5712-467F-A164-37A973483CC7) (Shutdown)
    iPad (5th generation) (6D8E17AD-08FD-4B91-B255-0B9B195775C8) (Shutdown)
    iPad Pro (9.7-inch) (A094F81B-74B1-485F-92C9-8B2FD2E1AD3E) (Shutdown)
    iPad Pro (12.9-inch) (4248B87E-17B0-4947-BC75-62B288B54340) (Shutdown)
    iPad Pro (12.9-inch) (2nd generation) (0B07A6FF-1701-4DF3-B952-F15606365702) (Shutdown)
    iPad Pro (10.5-inch) (619EEF68-C205-421E-A8FF-BD7E94D41F10) (Shutdown)
    iPad (6th generation) (33CCB6E5-C6F1-4F93-A5EB-B18F79C92269) (Shutdown)
    iPad Pro (11-inch) (9441B5F2-65C4-4AD9-BF59-D1EDBA6FA6AE) (Shutdown)
    iPad Pro (12.9-inch) (3rd generation) (39363B4E-E743-42C9-86EA-F8BDCFB51175) (Shutdown)
-- tvOS 12.4 --
-- watchOS 5.3 --

Automation for the win!

Comments