After i upgrade my Xcode to version 10.3, i found all the iOS simulator which i used before has lost. And when i build or run the iOS app in Xcode, it will use Generic iOS Device only ( you can see it in below picture ), but i do not have a real iOS device connected to my Mac computer at all, so the build will failed. So i need to add iOS simulator to the Xcode again to build and run my iOS app. This article will tell you how to do it.
1. How To Download iOS Simulators Package In Xcode.
- Click Set the active scheme drop down list in Xcode toolbar, then click Download Simulators item.
- If you can not find the Download Simulator item at above picture, you can click Xcode —> Preferences menu item at Xcode top menu bar.
- Then click Components tab to open iOS simulator download dialog like below. Click the down arrow before the iOS simulator which you need to download it, after download click Check and Install Now button to install it.
2. How To Add / Remove iOS Simulator From Xcode.
After download selected version iOS simulator package, by default it will install all the iOS simulator of that version in the Xcode, you can add more or remove special iOS simulator from Xcode follow below steps.
- Click Window —> Devices and Simulators menu item at Xcode top menu bar.
- There are two tabs in the popup dialog window, click the Simulators tab, then click the plus icon (
+) at bottom left corner of the popup dialog window to open add simulator dialog. Give the simulator a name, select related Device Type and OS Version, then click Create button to create a new simulator. After this action, you can see the newly created iOS simulator at left list panel.
- If you want to remove one iOS simulator, just right click it in left simulator list, then click Delete menu item in the popup menu list.
3. How To Reinstall Downloaded iOS Simulator Package In Xcode.
If you want to fully remove one iOS simulator version package from Xcode and then reinstall it again, you can follow below steps.
- Open a terminal and go to directory /Library/Developer/CoreSimulator/Profiles/Runtimes, you can find all the downloaded iOS simulator package directory files in it like below.
# go to iOS simulator package install directory. $ cd /Library/Developer/CoreSimulator/Profiles/Runtimes # display current directory path. $ pwd /Library/Developer/CoreSimulator/Profiles/Runtimes # list all the iOS simulator package directory files that has been installed. $ ls -l total 0 drwxrwxr-t 3 root admin 96 Sep 3 22:48 iOS 12.0.simruntime drwxrwxr-t 3 root admin 96 Aug 14 21:59 iOS 12.1.simruntime drwxrwxr-t 3 root admin 96 Aug 14 20:50 iOS 12.2.simruntime
- Then you can remove the iOS simulator packages which you do not need use below command.
$ sudo rm -rf ./iOS\ 12.2.simruntime/ Password:
- Now, you can restart Xcode to download and reinstall the removed iOS simulator packages which you need follow section 1 of this article.
4. How To Use The Newly Created iOS Simulator.
- After create iOS simulator follow above steps, when you click Set the active scheme drop down list at Xcode tool bar, you can find and select the iOS simulator to run your code.
- If you still can not find the iOS simulator that you added, this may be because you choose wrong iOS Deployment Target version than which you downloaded. You can change the iOS Deployment Target version by click the Xcode project name ( TestProject ) in Xcode left navigator pane, then click the project name ( TestProject ) in the center editor PROJECT pane, then click Info tab, and change the iOS Deployment Target version in the Deployment Target section.