node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/findMatchingSimulator.js
网上的修改react-native/..文件都是错误的,因为重点在@react-native-community中.
解决办法1:直接在XCode中创建iPhone X模拟器:xcode中点击 Window > Devices and Simulators>点击加号+>Device type选择iPhone X > Create > 完成! 此时运行react-native run-ios 已经可以了!
官方原文:
Create a simulator configuration
If you don’t see the device type with the operating system version you want to test in Simulator, you can create a custom configuration using the Devices and Simulators window. The new simulator will appear in the run destination of the scheme menu in the toolbar.
-
Open the Devices and Simulators window (choose Window > Devices and Simulators), then click Simulators.
-
In the lower-left corner, click the Add button (+).
-
In the sheet that appears, enter a simulator name, choose a device type, and choose an operating system version.
-
If you don’t see the operating system version you want to use, choose “Download more simulator runtimes.”
The Components preferences opens where you can download and install simulator runtimes.
-
Click Create.
解决方法2:(下面一顿操作,没有实质卵用)手动打开模拟器:
然后
Hardware, Device, iOS 13.0.
将看到: - iPhone 8 - iPhone 8 Plus - iPhone XS - iPhone XS Max - iPhone XR - ...
选择某一个,比如最新的iPhone 11 Pro Max
然后执行命令:react-native run-ios --simulator="iPhone 11 Pro Max"
漫长的等待..OK!
如果还不行:接下来
node_modules/@react-native-community/cli/build/commands/runIOS/findMatchingSimulator.js修改该文件下的
-
if (
-
simulator.availability !== '(available)' &&
-
simulator.isAvailable !== 'YES'
-
) {
-
continue;
- }
- 将'YES'改为true即可 如:
-
if (
-
simulator.availability !== '(available)' &&
-
simulator.isAvailable !== true
-
) {
-
continue;