Xcode Simulator: how to remove older unneeded devi

2019-01-16 00:13发布

I'm running Xcode 4.3.1 iOS-Simulator which originally only supports iOS 5.1.

I need to test my code with iOS 4.3, so I used Xcode's "Install" feature to install it as described in "Installing Xcode with iOS 4.3 device simulator?"

Now I'm finished with testing but cannot find a way to uninstall the 4.3 portions ("iPhone 4.3 Simulator" and "iPad 4.3 Simulator"). I want to reduce the clutter in the Scheme menu.

No one on Apple's Xcode listserv knew the answer!

EDIT: note that much has changed since Xcode 4.3, so suggest anyone reading this look at all the answers. The newest ones such as Steve Moser's may be of more use to you!

EDIT 10/2017: Posted on Twitter by Julio Carrettoni‏

If you are an iOS developer, execute this:
$ xcrun simctl delete unavailable
It removes old simulators Xcode no longer use. For me it was 6Gb Did not try it myself...

[Also, I just saw Russ Bishop mentioned this in a comment below already...]

14条回答
姐就是有狂的资本
2楼-- · 2019-01-16 00:46

Xcode 4.6 will prompt you to reinstall any older versions of the iOS Simulator if you just delete the SDK. To avoid that, you must also delete the Xcode cache. Then you won't be forced to reinstall the older SDK on launch.

To remove the iOS 5.0 simulator, delete these and then restart Xcode:

  1. /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/PhoneSimulator5.0.sdk
  2. ~/Library/Caches/com.apple.dt.Xcode

For example, after doing a clean install of Xcode, I installed the iOS 5.0 simulator from Xcode preferences. Later, I decided that 5.1 was enough but couldn't remove the 5.0 version. Xcode kept forcing me to reinstall it on launch. After removing both the cache file and the SDK, it no longer asked.

查看更多
Root(大扎)
3楼-- · 2019-01-16 00:47

October 2018 update

As was mentioned, you can use xcrun to do a few things:

  • xcrun simctl list devices or xcrun simctl list --json to list all simulators
  • xcrun simctl delete <device udid> to delete specific device
  • xcrun simctl delete unavailable to remove old devices for runtimes that are no longer supported

More things you can do with xcrun (see code snippet)

- `xcrun simctl boot <device udid>` to launch (multiple) simulators
- `xcrun simctl io booted recordVideo — type=mp4 ./test.mp4` to record simulator video
- `xcrun simctl io booted screenshot ./screen.png` to make screenshot of simulator
- `xcrun simctl openurl booted https://google.com` to open URL in simulator
- `xcrun simctl addmedia booted ./test.mp4` to upload photo or video file (for photos app)
- `xcrun simctl get_app_container booted <your apps bundle identifier>` to find the app container (where identifier is like *com.bundle.identifier*)
- `xcrun simctl help` to explore **more** commands

Original Answer

September 2017, Xcode 9

Runtimes

You will find them here:

/Library/Developer/CoreSimulator/Profiles/Runtimes

enter image description here

Devices

To delete devices go here:

~/Library/Developer/CoreSimulator/Devices

Much easier to delete them use Xcode: Xcode->Window->Devices and Simulators enter image description here

Helping Xcode "forget" about runtimes and prevent from re-installing them - delete .dmg file(s) here:

~/Library/Caches/com.apple.dt.Xcode/Downloads

I hope it will help someone

查看更多
欢心
4楼-- · 2019-01-16 00:49

In XCode open Window - Devices, then select and remove the outdated simulators.

查看更多
我欲成王,谁敢阻挡
5楼-- · 2019-01-16 00:50

I had the same problem. I was running out of space. Deleting old device simulators did NOT help.

The root cause was xCode keeping every iOS versions since I had installed xCode.

Delete the iOS version you don't want and free up disk space.I saved 50GB+ of space.

enter image description here If you have multiple macOS users on a single machine, make sure to find this directory with the user account that originally installed xCode.

查看更多
smile是对你的礼貌
6楼-- · 2019-01-16 00:52

The problem with these answers is that, with every Xcode update, menus and locations will change.

Just go to /Applications/Xcode.app/Contents/Developer/Platforms and delete what you don't need. Xcode will start fine. If you're at all concerned then you can simply restore from Trash.

查看更多
Animai°情兽
7楼-- · 2019-01-16 00:53

In Xcode 6 and above, you can find and delete the simulators from the path /Library/Developer/CoreSimulator/Profiles/Runtimes. Restart Xcode in order to take effect (may not be needed).

查看更多
登录 后发表回答