我今天升级到了Xcode 10.2,因为升级后我无法通过cli运行react-native run-ios:

react-native run-ios --simulator="iPhone X"

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)    

如果我运行xcrun simctl list devices,所有模拟器都会显示(Shutdown) (unavailable, runtime profile not found):

iPhone X (7AADFA50-7B57-4A40-8434-9A86F345D7ED) (Shutdown) (unavailable, runtime profile not found)

自从将xcode升级到10.2以后,还有其他人在RN上遇到过这个问题吗?它仍然可以通过Xcode工作..但这意味着要打开Xcode.

推荐答案

我这样解决;

首先,你需要走这条路

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'))

我希望这会有帮助,

参考:https://github.com/facebook/react-native/issues/21498#issuecomment-476621627

React-native相关问答推荐

在Reaction Native With EXPO中播放来自OpenAI TTS API的音频响应

构建 iOS Expo 应用时出现 React-Native xcodebuild 错误 65

单击react 本机时如何从同一屏幕更改内容

将屏幕标题更新为所选标签导航的标题

如果没有启用远程调试器,React Native 代码将无法工作

Google SignIn SDK 因抛出错误而失败,发生不可恢复的登录失败 -catch 错误

警告:API 'variant.getMergeAssets()' 已过时 / Android Studio 3.3

'React native run android' 在模拟器中启动应用程序后立即停止

如何运行 React-Native 示例?

React Native 开发中的/ios/index/DataStore文件夹是什么

在 UIManager 中找不到RNCSafeAreaView

Fragment片段内的react-native

自定义标签栏react Navigation 5

> 任务 :app:checkDebugAarMetadata 在运行 react-native run-android 时失败

按钮的标题属性必须是字符串

无法解析模块react-native-reanimated

React Native,AppStore 请求 NSLocationAlwaysUsageDescription 值

Jest TransformIgnorePatterns 所有 node_modules 用于 React-Native Preset

python 3与本机兼容吗?还是我应该按照 react 文档的建议安装 python 2?

React Native 项目,有时使用 expo start 获得连接 ECONNREFUSED 127.0.0.1:19001