react-native run-ios can not find any simulator

后端 未结 8 682
滥情空心
滥情空心 2020-12-03 08:07

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 t

8条回答
  •  [愿得一人]
    2020-12-03 08:59

    I solved it by replacing line number 62 in YourProjectFolder/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

    This line

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

    With this one

    if (
          !simulator.isAvailable
       ) {
    

    In some case there may be some different solutions for everyone just debug findMatchingSimulator.js file by putting console.log() so you'll know why it is not detecting simulator. In my case the xcrun simctl list devices --json command not providing simulator.availability and simulator.isAvailable is not string it's bool. I printed the simulator list which command is returning through the following line

      console.log(JSON.stringify(simulator.simulatorName));
      console.log(simulator.isAvailable);
      console.log('-------------------------------------------------------------');
    

    The after running command react-native run-ios --simulator="iPhone SE" I got output in the terminal and fixed code according to console print. And my simulator was running.

提交回复
热议问题