react-native: react-native run-ios can not find any simulator

Environment

React Native Environment Info: System: OS: macOS 10.14.2 CPU: (12) x64 Intel® Core™ i9-8950HK CPU @ 2.90GHz Memory: 6.76 GB / 32.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.15.0 - /usr/local/bin/node Yarn: 1.13.0 - /usr/local/bin/yarn npm: 6.4.1 - /usr/local/bin/npm SDKs: iOS SDK: Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1 IDEs: Android Studio: 3.1 AI-173.4819257 Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: react: 16.6.3 => 16.6.3 react-native: 0.57.8 => 0.57.8 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1 react-native-git-upgrade: 0.2.7

Description

I have been facing an issue where ‘react-native run-ios’ can not start, regardless of the simulator I add to the --simulator argument. XCode has the correct location for the ‘command line tools’

I am always getting the error: Could not find iPhone X simulator

Error: Could not find iPhone X simulator
    at resolve (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
    at new Promise (<anonymous>)
    at runOnSimulator (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
    at Object.runIOS [as func] (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
    at Promise.resolve.then (/Users/eric/.../swim/node_modules/react-native/local-cli/cliEntry.js:117:22)

Reproducible Demo

Installed XCode from scratch. Brand new ‘react-native new app’

‘react-native run-ios’ always complain about not finding the simulator, regardless of the --simulator option.

My temporary fix is to change: /node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

line 42, to: if (!version.startsWith(‘**com.apple.CoreSimulator.SimRuntime.**iOS’) && !version.startsWith(‘tvOS’)) {

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 14
  • Comments: 107 (6 by maintainers)

Commits related to this issue

Most upvoted comments

It’s having issues doing the string search on the simulator version in node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js on this line: if (!version.startsWith('iOS').

I replaced it with includes as such: if (!version.includes('iOS') which seems to have solved the problem for me.

I have the same issue here as well. When I changed to if (!version.includes(‘iOS’) && !version.includes(‘tvOS’)) { continue; }

all is well, since the prefix “com.apple.CoreSimulator.SimRuntime.” is included in the device-list, the pure check for startsWith fails for all simulators.

For anyone that is unable to upgrade RN but it needing a more automated fix, you can use the following shell script in your postinstall:

sed -i '' 's/startsWith/includes/g' node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

This helped us to be able to execute our automation tests on our CI server.

Updated to xcode 11. couldn’t find device. problem is with interpreting the output of xcrun simctl list --json devices that’s used by the script to find out installed devices. Went into the code of findMatchingSimulator. in the condition stating

            if (
                simulator.availability !== '(available)' &&
                simulator.isAvailable !== 'YES'
            ) {
                continue
            }

added new form of isAvailable (Which is now a plain boolean):

            if (
                simulator.availability !== '(available)' &&
                simulator.isAvailable !== 'YES' &&
                simulator.isAvailable !== true
            ) {
                continue
            }

this sorted things out.

  1. Can you check which iOS simulator are installed on your machine?
  2. You can always pass which simulator you want to target via the react-native run-ios —device=“XXXXXX’

easy fix…

Xcode -> preferences -> components install ios 12.2 sumulator

Today I’ve fixed that in runIOS/findMatchingSimulator.js. 🎉 I changed the line if (simulator.availability !== '(available)' && simulator.isAvailable !== 'YES') { to if (simulator.availability !== '(available)' && simulator.isAvailable !== true) {. It seems the isAvailable property returns normal boolean instead of YES/NO in the devices list. By the way, I had this issue after installing Xcode 11 Beta.

Another option that works for me.

# to find what simulators you have
xcrun simctl list

# to run a specific simulator
rn run-ios --simulator "iPhone 11"

Updated to xcode 11. couldn’t find device. problem is with interpreting the output of xcrun simctl list --json devices that’s used by the script to find out installed devices. Went into the code of findMatchingSimulator. in the condition stating

            if (
                simulator.availability !== '(available)' &&
                simulator.isAvailable !== 'YES'
            ) {
                continue
            }

added new form of isAvailable (Which is now a plain boolean):

            if (
                simulator.availability !== '(available)' &&
                simulator.isAvailable !== 'YES' &&
                simulator.isAvailable !== true
            ) {
                continue
            }

this sorted things out.

Awesome. This works like a charm. Thanks man

Same error following a recent Xcode update which added new phone simulators AND removed some older ones:

  1. Launch Simulator
  2. From menus: Hardware > Device > Manage Devices
  3. Choose “Simulators” tab/button, then click the “+” at the bottom left and add whatever device your run error is complaining about (take the defaults - i.e., don’t fill in the name field).

Hope this helps someone…

@TchernyavskyDaniil You save my time. Tks so much! RN 0.58.3 Xcode 11 Having this issue. Fix this issue by follow below step:

  1. From project open file: code ./node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
  2. replace version.indexOf(‘iOS’) !== 0 to !version.includes(‘iOS’)

replace simulator.availability !== ‘(available)’ to simulator.availability !== ‘(available)’ && simulator.isAvailable !== ‘YES’ && simulator.isAvailable !== true 3. Run react-native run-ios By default react native will run simulator iPhone 11 Pro Max. See list current simulator: xcrun simctl list devices You can change simulator: react-native run-ios --configuration Debug --simulator='Your simulator' --scheme 'Your Scheme' Example react-native run-ios --configuration Debug --simulator='iPhone 11 Pro Max' --scheme 'HelloWorld'

Hi All,

I found other solution without changing any source code in node_modules directory.

  1. Create react-native project folder (command: react-native init projectName)
  2. Open file projectName/ios/projectName.xcodeproj file in Xcode 11
  3. Choose device that you want to use (iPhone X not in list anymore after releasing iPhone Pro, so you need click on plus button and add to current list of devices)
  4. When your new device in list you can close Xcode 11 and try to run emulator from Terminal (react-native run-ios)

if you need any screenshots how to do that just let me know.

This is my first comment in github by the way so congrats me 😃

Thank you.

Is the iPhone X simulator no longer supported? I was running into this issue and fixed it by running -simulator="iPhone 11 Pro"

I think my issue might have to do with the fact that if you’re on XCode 10.2.1 (like I am), Apple renamed the iPhone XR simulator to iPhone Xʀ (notice the big “R” vs the little “ʀ”) so if you’re trying to target that newly renamed simulator, use react-native run-ios --simulator="iPhone Xʀ". Thanks Apple…

@topik96 Check here.

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

Note: The fixes above didn’t work for me. What I did:

  1. Run this command xcrun simctl list devices
  2. Check the simulator name and iOS version. (In my case it was 12.2)
  3. Now my command looks like this react-native run-ios --simulator='iPad Pro (9.7-inch) (12.2). Notice the iOS version.

Previously, I didn’t mention the iOS version in my run command.

For anyone that is unable to upgrade RN but it needing a more automated fix, you can use the following shell script in your postinstall:

sed -i '' 's/startsWith/includes/g' node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

This helped us to be able to execute our automation tests on our CI server.

This worked for me

This is working for me at 0.58.6; It looks like it was fixed in the commit 9a8c9596ebe41e27d37ba18d6bf09f1c931c1ff2 🙂

After upgrading to Xcode 11, I get an error “Could not find “iPhone X” simulator.”

@evanoralph If you got this issue today like me you can try to modify the findMatchingSimulator.js in node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js. First boot a Simulator then run xcrun simctl list --json devices and search the one with "state" : "Booted",. Then add at the top in the findMatchingSimulator function:

return {
    udid: <uuid from booted device>,
    name: <Name of the booted simulator>,
    booted: true,
    version: "com.apple.CoreSimulator.SimRuntime.iOS-12-2",
}

version might vary. But it is the parent key of the booted device object. But this is not a fix! It is a workaround.

If you’re still experiencing the error after following @dmurchie’s steps above, you may need to also update your @react-native-community/cli.

You can follow the steps here to do so: https://github.com/react-native-community/cli#updating-the-cli

Am I the only one who does not have node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js ? There is only one thing inside the local-cli folder, which is the file cli.js - any ideas??

It’s having issues doing the string search on the simulator version in node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js on this line: if (!version.startsWith('iOS').

I replaced it with includes as such: if (!version.includes('iOS') which seems to have solved the problem for me.

awesome thanks !!

I found this the simplest,

react-native run-ios --simulator "iPhone 11 Pro Max"

THIS MIGHT ME HELPFUL FOR SOMEONE STILL USING

“react-native”: “0.52.1”

I have fixed this with following change.

Go to this path.

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

Change (line number was 30 for me) if (version.indexOf('iOS') !== 0)

To if (version.indexOf('iOS') === -1)

Updated to xcode 11. couldn’t find device. problem is with interpreting the output of xcrun simctl list --json devices that’s used by the script to find out installed devices. Went into the code of findMatchingSimulator. in the condition stating

            if (
                simulator.availability !== '(available)' &&
                simulator.isAvailable !== 'YES'
            ) {
                continue
            }

added new form of isAvailable (Which is now a plain boolean):

            if (
                simulator.availability !== '(available)' &&
                simulator.isAvailable !== 'YES' &&
                simulator.isAvailable !== true
            ) {
                continue
            }

this sorted things out.

This worked to me! Thanks guy!

When you open .xcodeproj file in ios folder it will start Xcode IDE and there you will be able to choose particular simulator. See screenshots below.

You can choose device from this list. 1 3

But if you do not see iPhone X you can easily add it to your list of devices. 2 4 5 6

If you have any questions let me know. Thanks.

It’s having issues doing the string search on the simulator version in node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js on this line: if (!version.startsWith('iOS').

I replaced it with includes as such: if (!version.includes('iOS') which seems to have solved the problem for me.

unbelievable,thanks

@Titozzz Any updates on when this will be fixed? The temporary fix isn’t a team and git friendly way. I am ready to contribute if someone were to tell me how to proceed.

If you just want to run any specific device. It might be missing in Simulators list. To add a device do the following steps:

  1. Open Xcode
  2. Press Command+Shift+2 it will open Devices & Simulators option.
  3. Go to Simulators tab and press + icon on the left bottom and add iPhone X or any missing device you want.

react-native-cli: 2.0.1 react-native: 0.59.9

Got the same error that cannot find simulator.

Cause: When running react-native run-ios, the default simulator name is iPhoneX, which is not existing at all. The name for iPhoneX is either iPhoneXs, iPhoneXs Max or iPhoneXR Solution: modify code in node_modules/@react-native-community/cli/build/commands/runIOS/findMatchingSimulator.js

// change this line
// it was if (simulator.name ===simulatorName && !match) {
if (simulator.name.includes(simulatorName) && !match) {
        match = {
          udid: simulator.udid,
          name: simulator.name,
          booted,
          version
        };
      } // Keeps track of the first available simulator for use if we can't find one above.

For anyone struggling with this because you’re trying to run an iPad Pro simulator, the issue is that findMatchingSimulator.js thinks anything inside parentheses is the iOS version of the simulator you’re trying to run. So it’s trying to open the iPad Pro simulator with iOS Version 10.5-inch (or whatever simulator you’re trying to run). For obvious reasons this isn’t going to work.

The easiest workaround for this until a permanent fix is implemented is to rename the simulator to something that doesn’t include parentheses. In Xcode, click Window>Devices and Simulators, click the Simulators tab, then right click the simulator you’re working with to rename it.

Am I the only one who does not have node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js ? There is only one thing inside the local-cli folder, which is the file cli.js - any ideas??

@lpfunding here: node_modules/@react-native-community/cli/build/commands/runIOS/findMatchingSimulator.js

If doesn’t work after add iPhone X simulator in XCode

  1. Delete node_modules
  2. Delete yarn.lock or package-lock.json
  3. Run yarn or npm install

Updated to xcode 11. couldn’t find device. problem is with interpreting the output of xcrun simctl list --json devices that’s used by the script to find out installed devices. Went into the code of findMatchingSimulator. in the condition stating

            if (
                simulator.availability !== '(available)' &&
                simulator.isAvailable !== 'YES'
            ) {
                continue
            }

added new form of isAvailable (Which is now a plain boolean):

            if (
                simulator.availability !== '(available)' &&
                simulator.isAvailable !== 'YES' &&
                simulator.isAvailable !== true
            ) {
                continue
            }

this sorted things out.

It’s work for me. Thanks man!

@galkahana Thanks. That worked. But modifying node_modules are deadly hacks which should be avoided. Should raise a PR for that

Specifically for iPad Pro simulators (or any other simulator which includes something other than an iOS version in parentheses), this is still broken on the latest version of react-native.

Aside from that scenario it’s working fine.

This is working when you upgrade react-native to v59

ok, I will take a look tomorrow morning.

I have updated the description of the PR now to say a bit about when it startet happening and added some version information of XCode and xcrun

@kelvinlemus I have

react-native-cli: 2.0.1
react-native: 0.61.5

And i want to change default simulator “iPhone X” I’m trying to run react-native run-ios --simulator='iPhone XR' Or Others but in every time just iPhone X launched

@danielcampo 's suggestion of upgrading the CLI fixed it for me.

I had to add this to my package.json: "@react-native-community/cli": "@^1.12.0", as, for some reason, the lock wouldn’t upgrade paste 1.11.2 without it.

Now it finds simulators without problem.

“Could not find “iPhone X” simulator.”

изображение

Nice 😃

couldn’t work out the issue and needed a solution quickly, so I hacked around a quick fix.

console.log the devices, and hacked a return

in findMatchingSimulator.js just before if(match) {return match}

I hardcoded a return

  return {
    udid: 'BFBD0FA0-3104-4401-80BE-DC54CD7E3895',
    name: 'iPhone X',
    version: 'com.apple.CoreSimulator.SimRuntime.iOS-12-4'
  }

I have the same issue here as well. When I changed to if (!version.includes(‘iOS’) && !version.includes(‘tvOS’)) { continue; } all is well, since the prefix “com.apple.CoreSimulator.SimRuntime.” is included in the device-list, the pure check for startsWith fails for all simulators.

hi, my node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js doesn’t exist

if you’re using the new cli on an updated version of React Native, it’s going to found here instead:

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

I think my issue might have to do with the fact that if you’re on XCode 10.2.1 (like I am), Apple renamed the iPhone XR simulator to iPhone Xʀ (notice the big “R” vs the little “ʀ”) so if you’re trying to target that newly renamed simulator, use react-native run-ios --simulator="iPhone Xʀ". Thanks Apple…

Worked for me. Thx.

In case someone need to run in specified iOS version: react-native run-ios --simulator="iPhone 8 (12-0)" It was (12.0) before but changed to 12-0 after I updated my xcode to 10.2.1

@evanoralph If you got this issue today like me you can try to modify the findMatchingSimulator.js in node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js. First boot a Simulator then run xcrun simctl list --json devices and search the one with "state" : "Booted",. Then add at the top in the findMatchingSimulator function:

return {
    udid: <uuid from booted device>,
    name: <Name of the booted simulator>,
    booted: true,
    version: "com.apple.CoreSimulator.SimRuntime.iOS-12-2",
}

version might vary. But it is the parent key of the booted device object. But this is not a fix! It is a workaround.

the workaround is work fine to me now, i dont know if i have to update my projects to .59.0

It’s having issues doing the string search on the simulator version in node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js on this line: if (!version.startsWith('iOS').

I replaced it with includes as such: if (!version.includes('iOS') which seems to have solved the problem for me.

Awesome! Although temporary it’s working perfectly. Thanks!

It’s having issues doing the string search on the simulator version in node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js on this line: if (!version.startsWith('iOS').

I replaced it with includes as such: if (!version.includes('iOS') which seems to have solved the problem for me.

Updated to macOS 10.14.4 and XCode updated to 10.2 and this issue started happening for me. Your solution has helped (even though this is only a temporary solution).

It’s having issues doing the string search on the simulator version in node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js on this line: if (!version.startsWith('iOS').

I replaced it with includes as such: if (!version.includes('iOS') which seems to have solved the problem for me.

I really can’t comprehend how this situation even existed

@kelset yes, I believe the format of the list of devices has changed with the latest XCode.