React Native升级后执行pod install遇React-utils依赖找不到错误
React Native 0.62.2 升级到 0.72.10 后
pod install 报错:找不到 React-utils 依赖 将React Native版本从0.62.2升级至0.72.10后,在iOS目录下执行pod install时收到错误提示:
[!] Unable to find a specification for 'React-utils' depended upon by 'React-Core'
npx react-native info 输出
系统: 操作系统: macOS 14.3 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz 内存: 26.32 MB / 16.00 GB Shell: 版本: "5.9" 路径: /bin/zsh 二进制文件: Node: 版本: 16.0.0 路径: /usr/local/bin/node Yarn: 版本: 1.22.19 路径: /usr/local/bin/yarn npm: 版本: 7.10.0 路径: /usr/local/bin/npm Watchman: 版本: 2023.12.04.00 路径: /usr/local/bin/watchman 包管理器: CocoaPods: 版本: 1.15.2 路径: /Users/gsantos/.rbenv/shims/pod SDK: iOS SDK: 平台: - DriverKit 23.2 - iOS 17.2 - macOS 14.2 - tvOS 17.2 - visionOS 1.0 - watchOS 10.2 Android SDK: 未找到 IDE: Android Studio: 2023.1 AI-231.9392.1.2311.11255304 Xcode: 版本: 15.2/15C500b 路径: /usr/bin/xcodebuild 编程语言: Java: 未找到 Ruby: 版本: 3.0.6 路径: /Users/gsantos/.rbenv/shims/ruby npm包: "@react-native-community/cli": 未找到 react: 已安装: 18.2.0 期望版本: 18.2.0 react-native: 已安装: 0.72.10 期望版本: 0.72.10 react-native-macos: 未找到 全局npm包: "*react-native*": 未找到 Android配置: hermesEnabled: false newArchEnabled: false iOS配置: hermesEnabled: 未找到 newArchEnabled: false
错误日志/堆栈追踪
RNFBAnalytics: 使用 Firebase/AnalyticsWithoutAdIdSupport 替代默认的 Firebase/Analytics 为Pod RNFBApp添加自定义脚本阶段: [RNFB] Core Configuration 为目标 `<app-name>` 自动链接React Native模块: RNAppleAuthentication, RNCMaskedView, RNCPushNotificationIOS, RNDateTimePicker, RNExitApp, RNFBAnalytics, RNFBApp, RNFS, RNFastImage, RNFileViewer, RNGestureHandler, RNImageCropPicker, RNKeychain, RNPermissions, RNReanimated, RNScreens, RNSentry, RNSoundPlayer, ReactNativeExceptionHandler, intercom-react-native, react-native-background-timer, react-native-config, react-native-document-picker, react-native-fbsdk-next, react-native-image-picker, react-native-netinfo, react-native-pager-view, react-native-pspdfkit, react-native-render-html, react-native-safe-area-context, react-native-simple-toast, react-native-track-player, react-native-udp, react-native-video, react-native-webview, 和 rn-fetch-blob 分析依赖 从 `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec` 获取DoubleConversion的podspec [Codegen] 找到FBReactNativeSpec 从 `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec` 获取RCT-Folly的podspec RNFBAnalytics: 使用 Firebase/AnalyticsWithoutAdIdSupport 替代默认的 Firebase/Analytics 从 `../node_modules/react-native/third-party-podspecs/glog.podspec` 获取glog的podspec /Users/gsantos/Projects/<project_name>/node_modules/react-native-fbsdk-next/react-native-fbsdk-next.podspec:4: 警告: 常量Pod::FBSDKVersion已初始化 /Users/gsantos/Projects/<project_name>/node_modules/react-native-fbsdk-next/react-native-fbsdk-next.podspec:4: 警告: FBSDKVersion之前的定义在此处 [!] 找不到React-Core依赖的React-utils的specification 你可能遇到以下情况之一: * 源仓库过期,可通过`pod repo update`或`pod install --repo-update`更新。 * 名称或版本输入错误。 * 未将托管Podspec的源仓库添加到Podfile中。
已尝试的操作:
- 升级CocoaPods到最新版本1.15.2
- 升级Ruby到3.0.6
- 执行
pod install --repo-update,问题仍未解决
解决方案
清理缓存与依赖文件
- 进入iOS目录,删除
Pods文件夹和Podfile.lock文件 - 执行
pod cache clean --all清理本地Pod缓存 - 返回项目根目录,删除
node_modules、package-lock.json和yarn.lock,重新执行yarn install或npm install
- 进入iOS目录,删除
检查Podfile配置
确保Podfile顶部包含RN 0.72.x要求的配置,删除任何手动添加的过时React组件依赖:require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'修复react-native-fbsdk-next的重复定义警告
升级react-native-fbsdk-next到适配RN 0.72.x的版本,或者临时修改其podspec文件,删除重复定义FBSDKVersion的行。重新执行pod安装
进入iOS目录,执行:pod install --repo-update
内容的提问来源于stack exchange,提问作者Gustavo Santos
相关产品推荐
相关产品推荐

