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
Here is additional temporary fix too. I am using Catalina.
I this file:
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
Change line 42 to:
if (!version.includes('iOS') && !version.includes('tvOS')) {
Change line 52-53 from:
simulator.availability !== '(available)' &&
simulator.isAvailable !== 'YES'
to:
simulator.isAvailable !== true
because the returned json list from command xcrun simctl list --json devices
, the property isAvailable is boolean and didn't have property 'availability'.
Just 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>, // 'BFA2D7D0-AD49-472F-8279-585DDBBF9151'
name: <Name of the booted simulator>, //"iPhone X"
booted: true,
version: "com.apple.CoreSimulator.SimRuntime.iOS-13-1",
}
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.
Just do
npm install
Then it will show warnings, then fix them by using following command
npm audit fix
I tried like below
Open Xcode
. Then Preferences
-> Select Components
in Tabs.
Then install any one(or more) of the available simulators on the list. Preferably the recent one at the top.
It solves the problem.
Try this script from Terminal
sed -i '' 's/startsWith/includes/g' node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
Now run
react-native run-ios