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

Error: Could not find iPhone 6 simulator #21498

Closed
codetay opened this issue Oct 5, 2018 · 34 comments
Closed

Error: Could not find iPhone 6 simulator #21498

codetay opened this issue Oct 5, 2018 · 34 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@codetay
Copy link

codetay commented Oct 5, 2018

I got this error when i ran: react-native run-ios

Could not find iPhone 6 simulator

Error: Could not find iPhone 6 simulator
    at resolve (/Users/xman/Desktop/TEST_COM/APP/orderapp/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
    at new Promise (<anonymous>)
    at runOnSimulator (/Users/xman/Desktop/TEST_COM/APP/orderapp/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
    at Object.runIOS [as func] (/Users/xman/Desktop/TEST_COM/APP/orderapp/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
    at Promise.resolve.then (/Users/xman/Desktop/TEST_COM/APP/orderapp/node_modules/react-native/local-cli/cliEntry.js:117:22)
@react-native-bot
Copy link
Collaborator

We are automatically closing this issue because it does not appear to follow any of the provided issue templates.

Please make use of the bug report template to let us know about a reproducible bug or regression in the core React Native library.

If you'd like to propose a change or discuss a feature request, there is a repository dedicated to Discussions and Proposals you may use for this purpose.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. 📋No Template labels Oct 5, 2018
@ovaisahmed43
Copy link

same issue here

@HannanShaikYara
Copy link

same issue here. Please help.

Info:
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 1.26 GB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.11.0 - /usr/local/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
Android SDK:
Build Tools: 23.0.1, 25.0.0, 25.0.2, 26.0.1, 26.0.2, 26.0.3, 27.0.1, 27.0.3, 28.0.1
API Levels: 21, 22, 23, 25, 26, 27, 28
IDEs:
Android Studio: 3.1 AI-173.4907809
Xcode: 10.0/10A255 - /usr/bin/xcodebuild
npmPackages:
react: 16.5.0 => 16.5.0
react-native: 0.57.2 => 0.57.2
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-create-library: 3.1.2
react-native-git-upgrade: 0.2.7
react-native-scripts: 1.14.0

It works from XCode but command line it is not working.

@apoorv487
Copy link

This error is occurring because the response of "xcrun simctl list --json devices" got changed. "availability" is changed by "isAvailable"
Workaround :
Open file findMatchingSimulator.js --> Replace simulator.availability !== '(available)' with simulator.isAvailable !== 'YES'

@apoorv487
Copy link

This error is occurring because the response of "xcrun simctl list --json devices" got changed. "availability" is changed by "isAvailable"
Workaround :
Open file findMatchingSimulator.js --> Replace simulator.availability !== '(available)' with simulator.isAvailable !== 'YES'

Thank you very much. I was breaking my head from so many days.

Curious to know, who is at fault here? XCode? or React Native?

I would say XCode. Accordingly ReactNative code should be updated. I would like to add pull request for that but this issue is already been closed by bot. Any idea how could I do that?

@Admin-Teem
Copy link

Admin-Teem commented Mar 19, 2019

Same issue here. Editing :

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

This:

function findMatchingSimulator(simulators, simulatorName) {
  if (!simulators.devices) {
    return null;
  }
  const devices = simulators.devices;
  var match;
  for (let version in devices) {

    console.log(" version in devices ");
    console.log(version);

    // Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc)
    if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
        console.log(" expecting code to find iOS simulator version, but it fails. ");
      continue;
    }

shows me:

com.apple.CoreSimulator.SimRuntime.tvOS-12-1
 expecting code to find iOS simulator version, but it fails. 
 version in devices 
com.apple.CoreSimulator.SimRuntime.iOS-12-1
 expecting code to find iOS simulator version, but it fails. 
 version in devices 
com.apple.CoreSimulator.SimRuntime.tvOS-12-2
 expecting code to find iOS simulator version, but it fails. 
 version in devices 
com.apple.CoreSimulator.SimRuntime.watchOS-5-2
 expecting code to find iOS simulator version, but it fails. 
 version in devices 
com.apple.CoreSimulator.SimRuntime.watchOS-5-1
  expecting code to find iOS simulator version, but it fails. 
 version in devices 
com.apple.CoreSimulator.SimRuntime.iOS-12-2
 expecting code to find iOS simulator version, but it fails. 

So I guess the structure of version has changed, and this is breaking the code?

I'll point out that doing string matching, based on strings being passed in from other tools and even other eco-systems, is bound to be fragile. Not that I can think of an alternative.

@leotm
Copy link
Contributor

leotm commented Mar 26, 2019

In case anybody else stumbles here, my solution was different.

What fixed it for me was manually updating our node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js from

if (!version.startsWith('iOS') && !version.startsWith('tvOS'))

to

if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS'))

If you console.log(version), each is now prefixed with com.apple.CoreSimulator.SimRuntime.


Also looks like

simulator.isAvailable !== 'YES'

should now be

if (simulator.isAvailable !== true)

And for anybody now getting: Nullability Issue Pointer is missing a nullability type specifier

I've created a gist that fixes RCTLinkingManager.h here: https://gist.github.com/leotm/05e34468f25c29623a731692738e140e

And finally get a successful build with XCode 10.2 (10E125) \o/

@Kamahl19
Copy link

Kamahl19 commented Mar 27, 2019

After upgrading to Xcode 10.2 this needs to be done if you are still using RN 0.53

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

replace
if (version.indexOf('iOS') !== 0)
with
if (version.indexOf('com.apple.CoreSimulator.SimRuntime.iOS') !== 0)

@khacnha
Copy link

khacnha commented Mar 29, 2019

Thank @Kamahl19 , it work for me!

sandor11 added a commit to sandor11/react-native-newrelic that referenced this issue Mar 29, 2019
Addressing Issue wix-incubator#23 facebook/react-native#21498

If you follow the guidance given wix-incubator#23 (comment) then you can get this working. But if you need to build your app in a CI/CD environment, then no way to edit your node modules.

This change brings this bridge in line with the current NewRelic agent.
@jacquesdev
Copy link

@leotm - do you have any idea when or how this will be fixed in react-native? It seems that it will now affect everyone. I'm currently on 0.57.8, and experiencing this issue, but looks like even if you are on the latest version you still get this.

Updating the file in node_modules is not a good solution these are temporary files.

@lpfunding
Copy link

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

@ialmoqren
Copy link

ialmoqren commented Mar 31, 2019

In addition to what @leotm said,

I've found that some simulator names have changed in Xcode 10.2 (iOS 12.2 SDK),
iPhone XS becomes iPhone Xs
iPhone XS Max becomes iPhone Xs Max
iPhone XR becomes iPhone Xʀ

So instead of running,

react-native run-ios --simulator "iPhone XS Max"

You should run

react-native run-ios --simulator "iPhone Xs Max"

@leotm
Copy link
Contributor

leotm commented Apr 1, 2019

@leotm - do you have any idea when or how this will be fixed in react-native? It seems that it will now affect everyone. I'm currently on 0.57.8, and experiencing this issue, but looks like even if you are on the latest version you still get this.

Updating the file in node_modules is not a good solution these are temporary files.

Confirmed working with "react-native": "0.59.2" and an iPhone X simulator running iOS 12.1 (app doesn't appear to start with iOS 12.2).

Be prepared to update dependencies ⚔

@leotm
Copy link
Contributor

leotm commented Apr 1, 2019

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

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

@patrickgodinho
Copy link

patrickgodinho commented Apr 4, 2019

it works for me:

    if (!version.startsWith('iOS') && !version.startsWith('tvOS')) 

to

if (
      !version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS-12-2') &&
      !version.startsWith('tvOS')
    ) 

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

@Monte9
Copy link
Contributor

Monte9 commented Apr 7, 2019

@patrickgodinho your solution worked perfectly for me! Thanks 💯

@ahmadalfy
Copy link

@patrickgodinho can confirm, pretty solid and works fine.

@azimshaik
Copy link

azimshaik commented Apr 11, 2019

@patrickgodinho I can not this
if (!version.startsWith('iOS') && !version.startsWith('tvOS'))
part of code in
./node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
instead I see

function findMatchingSimulator(simulators, simulatorName) {
  if (!simulators.devices) {
    return null;
  }
  const devices = simulators.devices;
  var match;
  for (let version in devices) {
    // Making sure the version of the simulator is an iOS (Removes Apple Watch, etc)
    if (version.indexOf('iOS') !== 0) {
      continue;
    }
    for (let i in devices[version]) {
      let simulator = devices[version][i];
      // Skipping non-available simulator
      if (simulator.availability !== '(available)') {
        continue;
      }
      // If there is a booted simulator, we'll use that as instruments will not boot a second simulator
      if (simulator.state === 'Booted') {
        if (simulatorName !== null) {
          console.warn("We couldn't boot your defined simulator due to an already booted simulator. We are limited to one simulator launched at a time.");
        }
        return {
          udid: simulator.udid,
          name: simulator.name,
          version
        };
      }
      if (simulator.name === simulatorName && !match) {
        match = {
          udid: simulator.udid,
          name: simulator.name,
          version
        };
      }
      // Keeps track of the first available simulator for use if we can't find one above.
      if (simulatorName === null && !match) {
        match = {
          udid: simulator.udid,
          name: simulator.name,
          version
        };
      }
    }
  }
  if (match) {
    return match;
  }
  return null;
}

module.exports = findMatchingSimulator;

Can you please help ? @Monte9 @ahmadalfy

@fnLog0
Copy link

fnLog0 commented Apr 12, 2019

i am just updated react-native latest version "0.58.6"

@samparmenter
Copy link

Really shouldn't be updating the code contained in node_modules if you can avoid it. Anyone who doesn't have that fix will run into the same issue and any updates to the packages you edit will reverse the "fix".

@ialmoqren
Copy link

ialmoqren commented Apr 12, 2019

@samparmenter I can imagine the issues this hack will cause, what alternatives do you suggest?

@sonlexqt
Copy link

sonlexqt commented Apr 14, 2019

it works for me:

    if (!version.startsWith('iOS') && !version.startsWith('tvOS')) 

to

if (
      !version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS-12-2') &&
      !version.startsWith('tvOS')
    ) 

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

I changed the if condition to

if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS'))

(instead of the code above) and it's working for me!

@mcjohnalds
Copy link

To make patrickgodinho's fix more automatic, add

"scripts": {
  "postinstall": "sed -i '' \"s/version.startsWith('iOS')/version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS')/g\" ./node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js"
}

to your package.json.

When you or a coworker runs npm install, the bug will go away.

@Cnordbo
Copy link

Cnordbo commented Apr 16, 2019

Thanks @mcjohnalds ! Nice snippet!
Run it right away with npm run postinstall, or by triggering a new npm install on your project.

@jolic
Copy link

jolic commented Apr 19, 2019

If you start another simulator with XCode 12.2.1 to test the app on iPad you must change the version:

before
react-native run-ios --simulator='iPad Pro (11-inch) (12.2)'
now
react-native run-ios --simulator='iPad Pro (11-inch) (12-2)'

@Cnordbo
Copy link

Cnordbo commented Apr 23, 2019

i upgraded my react-native version to latest (last week) - and this seems to have been fixed in newer versions.
Trying to run the script proposed by @mcjohnalds on this version, yields an error that its unable to locate the text it wants to replace.

    "react": "16.8.3",
    "react-native": "^0.59.4",

@chanduthedev
Copy link

In case anybody else stumbles here, my solution was different.

What fixed it for me was manually updating our node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js from

if (!version.startsWith('iOS') && !version.startsWith('tvOS'))

to

if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS'))

If you console.log(version), each is now prefixed with com.apple.CoreSimulator.SimRuntime.

Also looks like

simulator.isAvailable !== 'YES'

should now be

if (simulator.isAvailable !== true)

And for anybody now getting: Nullability Issue Pointer is missing a nullability type specifier

I've created a gist that fixes RCTLinkingManager.h here: https://gist.github.com/leotm/05e34468f25c29623a731692738e140e

And finally get a successful build with XCode 10.2 (10E125) \o/

Thanks. It worked for me.

@iamcxa
Copy link

iamcxa commented May 9, 2019

To make patrickgodinho's fix more automatic, add

"scripts": {
  "postinstall": "sed -i '' \"s/version.startsWith('iOS')/version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS')/g\" ./node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js"
}

to your package.json.

When you or a coworker runs npm install, the bug will go away.

for anyone who looking for the solution about old version React Native project that runs failed on the newest XCode, please just using this as a workaround.

thank you for just saving my day :p

@369855707
Copy link

This error is occurring because the response of "xcrun simctl list --json devices" got changed. "availability" is changed by "isAvailable"
Workaround :
Open file findMatchingSimulator.js --> Replace simulator.availability !== '(available)' with simulator.isAvailable !== 'YES'

It dose not work for me. still get 'could not find iPhone 6 simulator' here

@ivanignacio
Copy link

@369855707 instead of 'YES' you have to use true
if (simulator.isAvailable !== true) {

@rsalunga29
Copy link

I tried everything you guys suggested but nothing works. I'm using Xcode 11 and React Native 0.60.5

@tunshiyu
Copy link

"react": "16.8.6",
"react-native": "^0.59.4",
by this i worked

@jacquesdev
Copy link

For me this was related to the xcode upgrade, with the default iPhone x simulator no longer available. I suggest specifiying iphone 11 instead

@iamcxa
Copy link

iamcxa commented Sep 26, 2019

I tried everything you guys suggested but nothing works. I'm using Xcode 11 and React Native 0.60.5

seems like XCode 11 has change something related to simulator keys, so these old fix method were no longer useful. for now if you still can't get it works, you can still start app within simulator by using XCode's run button.

@facebook facebook locked as resolved and limited conversation to collaborators Oct 5, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests