I downloaded the recently released Xcode 11 beta version, and now I can't run my React-Native app on my simulator. I know there are some question on stack-overflow about this but they did'nt help. the problem is there is no
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
file at all. in the local-cli
folder there is only one file named cli.js
'use strict';
var cli = require('@react-native-community/cli');
if (require.main === module) {
cli.run();
}
module.exports = cli;
Just type this command in Terminal: open -a Simulator. app to launch the most recent simulator. Type this command in Terminal to run the Simulator rigth from the its folder.
Starting the emulator Use the emulator command to start the emulator, as an alternative to running your project or starting it through the AVD Manager. Here's the basic command-line syntax for starting a virtual device from a terminal prompt: emulator -avd avd_name [ {- option [ value ]} … ]
Open Xcode and click Menu > Xcode > Preferences > Select Components, and then choose the simulator version you want to download.
error Could not find "iPhone X" simulator. Run CLI with --verbose flag for more details.
PROBLEM
If you try this with the latest Xcode (11), there is no iPhone X!
Run Simulator by itself, in the top menu, look under Hardware, Device, iOS 13.0.
You will see there is: - iPhone 8 - iPhone 8 Plus - iPhone XS - iPhone XS Max - iPhone XR - ... and some iPads
When you execute run-ios, react-native is designed to match a requested device.
The internally hard coded default is iPhone X.
The function that tries to match the requested device is in:
/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/findMatchingSimulator.js
This function is designed so you can give it a device, and an optional version number.
If the given device and version cannot be found, it will return a match using the first device in the list by default.
But... in reality, the first device is a watch, and any watch is excluded from matching, so this function will return null.
SOLUTION 1 - Use Existing Xcode iOS Device
Run Simulator first by itself, as described above, and make a note of which iPhone or iPad you want.
Then pass this name as an optional argument the the run-ios command line command as follows:
react-native run-ios --simulator="iPhone 8"
SOLUTION 2 - Add New Xcode iOS Device
According to Xcode 11 Release Notes:
"Xcode no longer creates every available iOS simulator device by default. Instead a set of the most commonly used devices are created. To create other devices — or multiple instances of a device — open the Devices window, select Simulators, click the + button, enter a name, and select the relevant device type and OS version. In Terminal, execute the xcrun simctl create command, for example xcrun simctl create "My iPhone 7" "iPhone 7" iOS13.0. (49428617)"
In Xcode, you need to add a new device called "iPhone X".
Also answered here:
error Could not find iPhone X simulator #418
If your project was created using react-native init, in your CLI< you should be able to type
xcrun simctl list devices
to get a list of all available simulators.
Scroll to the top to see list of available devices.
If you want to run Simulator with say iPhone XS Max, then just;
react-native run-ios --simulator="iPhone XS Max"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With