You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native iOS构建失败:RCTThirdPartyFabricComponentsProvider.h文件缺失

解决Expo + React Native 0.76.5构建iOS时缺失RCTThirdPartyFabricComponentsProvider.h的问题

问题原因

  1. React Native 0.76.x 对Fabric架构的文件结构做了重构,RCTThirdPartyFabricComponentsProvider.h 不再存放在React/Fabric/路径下,而是迁移到了React-CoreModules相关目录中。
  2. Expo预构建生成的Podfile配置未同步适配RN 0.76.5的新结构,导致构建时头文件搜索路径错误,找不到目标文件。

修复步骤

  • 强制重新生成Expo预构建配置
    执行命令彻底清理并重新生成iOS项目文件:

    npx expo prebuild --clean
    

    注意:这会覆盖原iOS目录的内容,若有自定义签名、权限配置等,先做好备份。

  • 手动修正Podfile的头文件搜索路径
    打开ios/Podfile,添加或修改以下配置,确保React-RCTFabric能找到正确的头文件路径:

    pod 'React-RCTFabric', :path => '../node_modules/react-native/Libraries/Fabric', :modular_headers => true
    
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        if target.name == 'React-RCTFabric'
          target.build_configurations.each do |config|
            config.build_settings['HEADER_SEARCH_PATHS'] ||= []
            config.build_settings['HEADER_SEARCH_PATHS'] += ['$(SRCROOT)/../node_modules/react-native/React/CoreModules']
          end
        end
      end
    end
    

    保存后进入iOS目录重新安装Pods:

    cd ios && pod install
    
  • 校验React Native依赖版本一致性
    执行命令查看RN依赖树,确认没有版本冲突:

    npm ls react-native
    

    若存在其他依赖间接引入不同版本RN,在package.json中添加resolutions字段锁定版本:

    "resolutions": {
      "react-native": "0.76.5"
    }
    

    之后重新安装依赖:npm install

  • 清理Xcode构建缓存
    打开Xcode,执行Product > Clean Build Folder(快捷键Cmd+Shift+K),关闭Xcode后重新执行构建命令:

    npx expo run:ios --device
    

内容的提问来源于stack exchange,提问作者jonas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 06:32:39