ReactNative开发踩坑记录

Could not find iPhone XXX

描述:

终端运行react-native run-ios时报错,无法找到模拟器,通过xcrun simctl list devices命令查看本地模拟器列表,已经包含了运行的模拟器

原因:

不能再通过cli运行react-native run-ios

解决方案:

进入/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js文件,将

1
if (!version.startsWith('iOS') && !version.startsWith('tvOS'))

修改为

1
if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS'))