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

Viewed 21813

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;
8 Answers

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

If your project was created using react-native init, in your CLI< you should be able to type xcrun simctl list devices to get a list of all available simulators. Scroll to the top to see list of available devices. If you want to run Simulator with say iPhone XS Max, then just; react-native run-ios --simulator="iPhone XS Max"

Adding the iPhone X simulator through the command line with:

/Applications/Xcode.app/Contents/Developer/usr/bin/simctl create "iPhone X" com.apple.CoreSimulator.SimDeviceType.iPhone-X com.apple.CoreSimulator.SimRuntime.iOS-13-0

solved the issue for me.

I too was stuck at this for a long time.One way to solve this is by making changes in the node_modules folder. Steps below.

  1. Go to node_modules/@react-native-community/cli/build/commands and open findMatchingSimulator.js
  2. Find the function findMatchingSimulator
  3. Once you go through the function, you will see that this function is returning the first matching simulator for opening your project.
  4. There is a line where we iterate over the devices and check if the device is available.
  5. Put a console.log before this check to get the details of each device.

       for (const i in device) {
           const simulator = device[i]; // Skipping non-available simulator
           console.log(JSON.stringify(simulator));
    
           if (simulator.availability !== '(available)' && simulator.isAvailable !== 'YES') 
           {
            continue;
           }
           ...................
    
  6. Now run your react-native run-ios command. You will see all the simulator device details getting printed in the console. Pick the one you like and replace return null with your desired simulator.

    In my case :

    return {
        udid: "E345U7U8-2213-11WQ-443D-OOJU7865P8J1",
        name: "iPhone 11",
        booted : false,
        version : null
      }

Run react-native run-ios again

go to Xcode > Open Developer tool > simulator > Add Simulator

Try this

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

I've got the same issue. Tried playing with the beta and got bit. I was able to open the .xcodeproj file in Xcode 10 and then run the simulator. I could then make changes in Atom and refresh the app in the simulator.

I made an update today to xcode, July 26 2019, and I got the same message. I did a simple reboot of the iMac, ran "react-native run-ios" and it was up and the simulator was up and running!

Related