升级 Xcode 10.2 之后无法使用 react-native run-ios ,报错如下:
Found Xcode workspace a.xcworkspace
Could not find iPhone X simulator
Error: Could not find iPhone X simulator
at resolve (/Users/user/Documents/work/a/a-light-ui/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
at new Promise (<anonymous>)
at runOnSimulator (/Users/user/Documents/work/a/a-light-ui/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
at Object.runIOS [as func] (/Users/user/Documents/work/a/a-light-ui/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
at Promise.resolve.then (/Users/user/Documents/work/a/a-light-ui/node_modules/react-native/local-cli/cliEntry.js:117:22)
解决方法:
找到 /项目地址/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
搜索下面这行代码
if (!version.startsWith('iOS') && !version.startsWith('tvOS'))
改为
if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS'))
现在试试 react-native run-ios 应该好了……