React Native iOS构建失败:无法在Derived Data目录找到依赖库
React Native构建失败:找不到DoubleConversion等Pod依赖库的解决方法
针对你遇到的Pod依赖已安装但构建时找不到库文件的问题,试试以下具体操作:
彻底清理缓存与构建产物
执行一系列清理命令,把旧的缓存和残留文件全部清掉:# 删除iOS目录下的Pods文件夹和Podfile.lock rm -rf ios/Pods ios/Podfile.lock # 清空CocoaPods的本地缓存 pod cache clean --all # 清理Xcode的构建缓存 xcodebuild clean -project ios/YourProjectName.xcodeproj -configuration Release # 删除Derived Data目录 rm -rf ~/Library/Developer/Xcode/DerivedData注意把
YourProjectName替换成你实际的项目名称。重新配置Podfile并重装Pods
打开ios/Podfile,确保顶部的React Native引入配置正确,并且手动指定核心依赖的podspec路径(避免自动引入出错):require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, '13.0' # 这里要和Xcode的目标iOS版本一致 target 'myperks' do config = use_native_modules! use_react_native!( :path => config[:reactNativePath], :hermes_enabled => true # 根据你的项目需求开启或关闭Hermes ) # 手动引入缺失的核心依赖 pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec' pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' post_install do |installer| react_native_post_install(installer) # 如果是M1/M2芯片的Mac,加上这行兼容代码 __apply_Xcode_12_5_M1_post_install_workaround(installer) end end保存后进入iOS目录重装Pods:
cd ios && pod install --repo-update检查Xcode的构建配置
打开Xcode中的myperks.xcworkspace(务必用xcworkspace,不要用xcodeproj),选中项目target后进入Build Settings:- 找到Framework Search Paths,确保包含
$(inherited)和$(PROJECT_DIR)/Pods/Headers/Public - 找到Library Search Paths,确保包含
$(inherited)和$(PROJECT_DIR)/Pods - 切换到Build Phases,检查Link Binary With Libraries里是否有DoubleConversion、RCT-Folly等库,如果没有,手动从
ios/Pods目录下找到对应的.framework文件添加进去
- 找到Framework Search Paths,确保包含
用Xcode直接构建测试
关闭所有Xcode窗口,重新打开ios/myperks.xcworkspace,选择正确的模拟器或真机,点击顶部的Build按钮,看是否还会出现路径错误的提示。核对Node与React Native版本兼容性
执行node -v和npx react-native info,确认你的Node版本符合当前React Native版本的官方要求(比如RN 0.70+需要Node 16.10及以上),版本不兼容也可能导致依赖引入异常。
内容的提问来源于stack exchange,提问作者chinds
相关产品推荐
相关产品推荐

