Search code examples
iosxcodereact-nativeios-simulator

Could not find iPhone X simulator. Run CLI with --verbose flag for more details


I downloaded the recently released Xcode 11 beta version, and now I can't run my React-Native app on my simulator. I know there are some question on stack-overflow about this but they did'nt help. the problem is there is no

/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

file at all. in the local-cli folder there is only one file named cli.js

'use strict';

var cli = require('@react-native-community/cli');

if (require.main === module) {
  cli.run();
}

module.exports = cli;

Solution

  • error Could not find "iPhone X" simulator. Run CLI with --verbose flag for more details.

    PROBLEM

    If you try this with the latest Xcode (11), there is no iPhone X!

    Run Simulator by itself, in the top menu, look under Hardware, Device, iOS 13.0.

    You will see there is: - iPhone 8 - iPhone 8 Plus - iPhone XS - iPhone XS Max - iPhone XR - ... and some iPads

    When you execute run-ios, react-native is designed to match a requested device.

    The internally hard coded default is iPhone X.

    The function that tries to match the requested device is in:

    /node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/findMatchingSimulator.js

    This function is designed so you can give it a device, and an optional version number.

    If the given device and version cannot be found, it will return a match using the first device in the list by default.

    But... in reality, the first device is a watch, and any watch is excluded from matching, so this function will return null.

    SOLUTION 1 - Use Existing Xcode iOS Device

    Run Simulator first by itself, as described above, and make a note of which iPhone or iPad you want.

    Then pass this name as an optional argument the the run-ios command line command as follows:

    react-native run-ios --simulator="iPhone 8"

    SOLUTION 2 - Add New Xcode iOS Device

    According to Xcode 11 Release Notes:

    "Xcode no longer creates every available iOS simulator device by default. Instead a set of the most commonly used devices are created. To create other devices — or multiple instances of a device — open the Devices window, select Simulators, click the + button, enter a name, and select the relevant device type and OS version. In Terminal, execute the xcrun simctl create command, for example xcrun simctl create "My iPhone 7" "iPhone 7" iOS13.0. (49428617)"

    In Xcode, you need to add a new device called "iPhone X".

    Also answered here:

    error Could not find iPhone X simulator #418