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 · 107 comments
Closed

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

eric-PearSports opened this issue Feb 3, 2019 · 107 comments
Labels
Bug Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.

Comments

@eric-PearSports
Copy link

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 has been minimized.

@eric-PearSports
Copy link
Author

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

and same issue

@kelset
Copy link
Contributor

kelset 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
Copy link

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
Copy link

I created pull request #23293 for this issue

@kelset
Copy link
Contributor

kelset 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
Copy link

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
Copy link
Author

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

@kelset
Copy link
Contributor

kelset 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
Copy link

@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
Copy link
Contributor

kelset commented Feb 5, 2019

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

@osunnarvik
Copy link

ok, I will take a look tomorrow morning.

@osunnarvik
Copy link

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

@keshavkaul
Copy link

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

@tedi
Copy link

tedi 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
Copy link

szm1002 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
Copy link

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
Copy link

YLD1 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
Copy link

are this fix with the new versions ?

@buschco
Copy link

buschco 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
Copy link

sabun123 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
Copy link

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

@Subway19
Copy link

Getting this error on XCode 11. God bless software updates !!

@maxkomarychev
Copy link
Contributor

you can update your @react-native-community/cli to 1.9.8 react-native-community/cli#414 (comment)

@Subway19
Copy link

@maxkomarychev

react-native --version
react-native-cli: 2.0.1
react-native: 0.59.8

@raldred
Copy link

raldred commented Sep 23, 2019

@maxkomarychev I'm using @react-native-community/cli@2.9.0 and having this issue.

@Subway19
Copy link

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

@heritiermwalila
Copy link

  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’

just install iphone X device in xcode

@dmurchie
Copy link

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

@danielcampo
Copy link

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

@marcoantoni0
Copy link

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

@pqminh
Copy link

pqminh commented Sep 25, 2019

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

@jamonholmgren
Copy link
Collaborator

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"

@KittiKing
Copy link

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!

@ilkinnamazov
Copy link

ilkinnamazov commented Sep 25, 2019

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.

@S-Cardenas
Copy link

@ilkinnamazov Could you send screenshots of your solution please?

@ilkinnamazov
Copy link

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.

@marcosalberto
Copy link

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

@lucianomlima
Copy link
Contributor

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

Delete lock files may be problematic under certain circumstances. Do it carefully

@avtarnanrey
Copy link

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.

@nanadjei
Copy link

Please kindly try this solution. It might work for you.

#24450 (comment)

@robincsamuel
Copy link

robincsamuel commented Oct 26, 2019

I found this the simplest,

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

@jamonholmgren
Copy link
Collaborator

This doesn't seem to be a problem anymore for me. Maybe some update in the meantime fixed it?

@njt1982
Copy link

njt1982 commented Nov 22, 2019

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

@prescindivel
Copy link

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!

grahammcculloch added a commit to appdevdesigns/adroit-mobile that referenced this issue Dec 2, 2019
@McMainsLiam
Copy link

If someone is still looking for the findMatchingSimulator.js file to manually edit it, you can currently find it at this path:
node_modules/@react-native-community/cli/build/commands/runIOS/findMatchingSimulator.js

I hope this helps someone down the line!

@kelvinlemus
Copy link

Also remember to pass IOS version within parenthesis:

--simulator "iPhone 11 Pro Max (13.2)"

@anastely
Copy link

@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

@facebook facebook locked as resolved and limited conversation to collaborators Mar 19, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests