Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native run-ios can not find any simulator #23282

Closed
eric-PearSports opened this issue Feb 3, 2019 · 63 comments

Comments

@eric-PearSports
Copy link

commented Feb 3, 2019

Environment

React Native Environment Info:
System:
OS: macOS 10.14.2
CPU: (12) x64 Intel(R) Core(TM) 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')) {

@react-native-bot

This comment was marked as resolved.

Copy link
Collaborator

commented Feb 3, 2019

It looks like you are using an older version of React Native. Please update to the latest release, v0.58 and verify if the issue still exists.

The "Resolution: Old Version" label will be removed automatically once you edit your original post with the results of running react-native info on a project using the latest release.

@eric-PearSports

This comment has been minimized.

Copy link
Author

commented Feb 4, 2019

just tried a brand new project with:
react-native: 0.58.3 => 0.58.3

and same issue

@kelset

This comment has been minimized.

Copy link
Collaborator

commented Feb 5, 2019

  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’
@osunnarvik

This comment has been minimized.

Copy link

commented Feb 5, 2019

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.

@osunnarvik

This comment has been minimized.

Copy link

commented Feb 5, 2019

I created pull request #23293 for this issue

@kelset

This comment has been minimized.

Copy link
Collaborator

commented Feb 5, 2019

Hey @osunnarvik thanks for creating the PR! Could you explain bit more (maybe in the PR) why is this happening now? I mean, when did the prefix changed? In latest Xcode? 🤔

@osunnarvik

This comment has been minimized.

Copy link

commented Feb 5, 2019

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

@eric-PearSports

This comment has been minimized.

Copy link
Author

commented Feb 5, 2019

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

@kelset

This comment has been minimized.

Copy link
Collaborator

commented Feb 5, 2019

Awesome - thanks folks :)

We have already merged the PR to 0.58 (since 0.59 etc will have the CLI separated) and next patch release (0.58.4) will have the fix 💪

@osunnarvik

This comment has been minimized.

Copy link

commented Feb 5, 2019

@kelset I noticed the comment in react-native-community/cli#138 regarding when you specify the simulatorString (comment from @canterberry ). I only checked with empty simulatorString and not with one set. Let me know if you would like me to take a look at the case where the simulatorString is set.

@kelset

This comment has been minimized.

Copy link
Collaborator

commented Feb 5, 2019

Uhm oh yeah probably it would be better to have the check also when the string is set. 🤔

@osunnarvik

This comment has been minimized.

Copy link

commented Feb 5, 2019

ok, I will take a look tomorrow morning.

@osunnarvik

This comment has been minimized.

Copy link

commented Feb 6, 2019

I created #23305 to handle dotted input-versions for simulatorString

@hramos hramos removed the Bug Report label Feb 6, 2019

@cpojer cpojer referenced this issue Mar 19, 2019
59 of 161 tasks complete

@Titozzz Titozzz closed this Mar 19, 2019

@keshavkaul

This comment has been minimized.

Copy link

commented Mar 22, 2019

@osunnarvik This issue is still present in react-native version 0.59.1

@tedi

This comment has been minimized.

Copy link

commented Mar 26, 2019

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.

@szm1002

This comment has been minimized.

Copy link

commented Mar 26, 2019

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.

It works for me.Thanks.

@dmateja724

This comment has been minimized.

Copy link

commented Mar 26, 2019

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 !!

@YLD1

This comment has been minimized.

Copy link

commented Mar 27, 2019

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

@evanoralph

This comment has been minimized.

Copy link

commented Mar 27, 2019

are this fix with the new versions ?

@buschco

This comment has been minimized.

Copy link

commented Mar 27, 2019

@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.

@sabun123

This comment has been minimized.

Copy link

commented Mar 27, 2019

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).

@j133y

This comment has been minimized.

Copy link

commented Mar 27, 2019

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!

@mickmak-busicat

This comment has been minimized.

Copy link

commented May 2, 2019

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

@react-native-bot react-native-bot added the Bug label May 4, 2019

@Susmitha-Bogala

This comment has been minimized.

Copy link

commented May 6, 2019

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.

this worked for me .thank you

but can you please explain me the problem

@anceque

This comment has been minimized.

Copy link

commented May 13, 2019

@kelset

Just to make sure I haven't missed anything: if you are on 0.59 this issue is fixed, correct?

i just upgraded to 0.59.8 and it works [upgraded via react-native-git-upgrade]

@hungvu193

This comment has been minimized.

Copy link

commented May 22, 2019

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

@gurmundi7

This comment has been minimized.

Copy link

commented Jun 11, 2019

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)

@djohnsonkc

This comment has been minimized.

Copy link

commented Jun 18, 2019

I'm using react-native@0.58.3 and --simulator="iPhone 8" was not being parsed correctly. When adding a console log, it seemed to be parsed as "iPhone (without an ending quote). I changed node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js to accept a simulator name with an underscore in place of any spaces.

This seems to fix the parsing issue I was seeing:

$ react-native run-ios --simulator="iPhone_8"

I made the following change locally:

function findMatchingSimulator(simulators, simulatorString) {
if (!simulators.devices) {
return null;
}
const devices = simulators.devices;

simulatorString = simulatorString.replace('_', ' ')

@ilyagru

This comment has been minimized.

Copy link

commented Jun 21, 2019

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.

@maplefu0601

This comment has been minimized.

Copy link

commented Jun 22, 2019

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.
@tuananhcwrs

This comment has been minimized.

Copy link

commented Jun 23, 2019

My project still use "react-native": "0.53.3" and for me the code in the "findMatchingSimulator.js" in react-native node_modules folder is

if (version.indexOf('iOS') != 0) {
continue;
}

Cannot believe it.

@ThanhPhat1080

This comment has been minimized.

Copy link

commented Jun 26, 2019

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.

Thanks It worked for me

@topik96

This comment has been minimized.

Copy link

commented Jul 4, 2019

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

@shihabmridha

This comment has been minimized.

Copy link

commented Jul 8, 2019

@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.

@houbaron houbaron referenced this issue Jul 15, 2019
@eric-PearSports

This comment has been minimized.

Copy link
Author

commented Jul 16, 2019

checking for available simulators should now be:
simulator.isAvailable !== true

@eranhr

This comment has been minimized.

Copy link

commented Jul 17, 2019

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.

@jrgarciadev

This comment has been minimized.

Copy link

commented Jul 19, 2019

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.

Thanks!, worked for me!

@jstheoriginal

This comment has been minimized.

Copy link
Contributor

commented Jul 24, 2019

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

@cihadturhan

This comment has been minimized.

Copy link

commented Jul 31, 2019

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.

I've installed 11 Beta too. It think this script should check both YES and true at the same time?

@brickion

This comment has been minimized.

Copy link

commented Jul 31, 2019

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'
  }
@tejparekh

This comment has been minimized.

Copy link

commented Aug 23, 2019

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.

Awesome. This works like a charm. Thanks!

@reactjsexample

This comment has been minimized.

Copy link

commented Sep 11, 2019

If you are seeing this error:

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

See my comment for this simple solution here:

error Could not find iPhone X simulator #418

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.