在执行npx react-native init MyProject时,我遇到了以下错误:

✖ Installing CocoaPods dependencies (this may take a few minutes)
error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.

这似乎与之前显示的错误有关:

checking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot 
checking whether the C compiler works... no
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'

XCode及其CLI似乎运行良好.

我的配置:

  • MacOS Catalina 10.15.1(19B88)
  • NPM 6.11.3
  • react 本机0.61.4
  • XCode 11.2.1(11B500)

感谢任何线索.

推荐答案

我发现了一个非常类似的错误,报告为here,其中solution表示:

sudo xcode-select --switch /Applications/Xcode.app

Reading around似乎表明,在更新行的某个地方,XCode CLI工具路径被设置为不正确的路径.

正如@bibin jaimon在下面的 comments 中所建议的,我的机器上确实有多个版本的XCode(为什么?因为https://stackoverflow.com/a/58329901/606351).

不管怎样,问题解决了.

React-native相关问答推荐

添加REACT-Native-SVG时出现错误-失败:构建失败并出现异常

1.5.1 nxworkspace+react-native 版本的Axios url未定义问题

如何在react native 中从 axios 重定向并将数据传递给路由

如何在堆栈的任何屏幕的后退按钮按下时始终导航到堆栈的初始路径?

react-native 根据状态隐藏显示按钮

FBSDK 和 LinkingManager 的 AppDelegate.m

如何在 react-native 中使用 Animated 制作 svg 动画

调用 ES6 方法时绑定上下文.如何从称为回调的方法中访问对象?

react native foreach 循环

react-native 从右到左

React Native 无法读取 index.android.delta

props验证中缺少 React Navigation 'navigation'

如果我有 AngularJS 基础知识,怎么学习Thinking in ReactJS呢?

使用 WSL2 运行时如何将手机连接到 expo

在 React Native 视图上强制 onLayout

xcode 10错误:multiple commands produce

react-navigation模式高度

为react-native TextInput 设置边框

React-Native 元素卡在 :app:installDebug

加载字体native-base 错误