Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find iPhone 6 simulator after upgrade to Xcode 10

I updated to Xcode 10 and since I did that, I can't run the simulator in terminal with the command react-native run-ios. I get this error:

Could not find iPhone 6 simulator

When I go to Xcode > Window > Devices and Simulator the simulator is there and when I do xcrun simctl list devices I also see the list of simulator.

I can run the app on my phone with react-native run-ios --device and from Xcode, and I tried with multiple apps so it's not the app.

When I go to Xcode > Preferences > Locations, Xcode 10.0 (10A255) is selected at Command Line Tools.

I tried restarting the computer, as well as deleting and re-installing Xcode.

Any ideas what it could be?

Here is my setup:

  • MacOs High Sierra 10.13.6
  • Xcode Version 10.0
  • react-native-cli: 2.0.1
  • react-native: 0.57.1
like image 607
Martin Leroux Avatar asked Oct 12 '18 16:10

Martin Leroux


3 Answers

I went to node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

And i've replaced:

if (version.indexOf('iOS') !== 0 )

with

if (!version.includes("iOS" ))

And

if (simulator.availability !== '(available)')

with

if (simulator.isAvailable !== true)

like image 93
samernady Avatar answered Oct 16 '22 12:10

samernady


I had similar issue. React Native - 0.52.3, XCode - 10.2 beta 2

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.includes('iOS')) {
      continue;
    }
    [...]
  }
}
  • Open file: node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

  • Check if your device version is correct, e.g: in line 29 console.log(version)

  • Compare it with condition in line 30: if (version.indexOf('iOS') !== 0) {

I had versions list like this:

com.apple.CoreSimulator.SimRuntime.watchOS-5-0 -1
com.apple.CoreSimulator.SimRuntime.tvOS-12-1 -1
com.apple.CoreSimulator.SimRuntime.tvOS-12-2 -1

Any of my versions doesn't return true in this condition... If you have it

  • Replace version.indexOf('iOS') !== 0 with !version.includes('iOS') and it solve this issue for me.
like image 41
Damian Avatar answered Oct 16 '22 13:10

Damian


The bug has been fixed in react-native so you can update the package in the package.json:

npm install -g npm-check-updates
ncu -u react-native
npm install
like image 41
Danny Sullivan Avatar answered Oct 16 '22 11:10

Danny Sullivan