无论我添加到--simulator参数的模拟器,我一直面临着'react-native run-ios'无法启动的问题。 XCode具有'命令行工具'的正确位置
我总是得到错误:找不到iPhone X模拟器
Error: Could not find iPhone X simulator
at resolve (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
at new Promise (<anonymous>)
at runOnSimulator (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
at Object.runIOS [as func] (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
at Promise.resolve.then (/Users/eric/.../swim/node_modules/react-native/local-cli/cliEntry.js:117:22)
反应原生信息
> React Native Environment Info:
> System:
> OS: macOS 10.14.2
> CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
> Memory: 6.76 GB / 32.00 GB
> Shell: 3.2.57 - /bin/bash
> Binaries:
> Node: 10.15.0 - /usr/local/bin/node
> Yarn: 1.13.0 - /usr/local/bin/yarn
> npm: 6.4.1 - /usr/local/bin/npm
> SDKs:
> iOS SDK:
> Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
> IDEs:
> Android Studio: 3.1 AI-173.4819257
> Xcode: 10.1/10B61 - /usr/bin/xcodebuild
> npmPackages:
> react: 16.6.3 => 16.6.3
> react-native: 0.57.8 => 0.57.8
> npmGlobalPackages:
> create-react-native-app: 1.0.0
> react-native-cli: 2.0.1
> react-native-git-upgrade: 0.2.7
我发现了一个临时修复:
在以下文件中:
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
...将第42行更改为:
if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('tvOS')) {
它在v1.9.8中修复。
更新cli是一个简单的解决方案
npm install -g react-native-cli@latest
此问题已修复但尚未发布。 https://github.com/react-native-community/react-native-cli/pull/274
因此可以暂时解决以修复下面的文件。
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
改变这一行
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
至
if (!version.includes('iOS') && !version.includes('tvOS')) {
不要忘记重新安装软件包时再次应用此项。
做就是了
npm install
然后它会显示警告,然后使用以下命令修复它们
npm audit fix
从终端尝试此脚本
sed -i''s / startsWith / includes / g'node_modules / react-native / local-cli / runIOS / findMatchingSimulator.js
现在跑
react-native run-ios