React Native新项目执行pod install报错,求问题排查与解决
问题描述
在新React Native项目中使用bundler执行pod install时遇到如下错误:
warn Multiple Podfiles were found: ios/Podfile,vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/Podfile. Choosing ios/Podfile automatically. If you would like to select a different one, you can configure it via "project.ios.sourceDir".
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
fatal: not a git repository (or any of the parent directories): .git
Analyzing dependencies
Fetching podspec forDoubleConversionfrom../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec
[Codegen] Found FBReactNativeSpec
Fetching podspec forRCT-Follyfrom../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec
Fetching podspec forboostfrom../node_modules/react-native/third-party-podspecs/boost.podspec
Fetching podspec forglogfrom../node_modules/react-native/third-party-podspecs/glog.podspec
Fetching podspec forhermes-enginefrom../node_modules/react-native/sdks/hermes/hermes-engine.podspec
[!] Couldn't determine repo type for URL:https://cdn.cocoapods.org/: Permission bits for '/Users/macbook/.netrc' should be 0600, but are 644
解决步骤
- 修复核心权限问题
错误根源是~/.netrc文件权限不符合CocoaPods的安全要求,执行以下命令修改权限:chmod 0600 ~/.netrc - (可选)消除git警告
日志中的git仓库警告不影响pod安装,若要移除该提示,在项目根目录执行:git init - 重新执行安装
再次运行bundler命令完成pod安装:bundle exec pod install
内容的提问来源于stack exchange,提问作者EddyWD

