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

RN 0.70.6升级至0.71.4后iOS构建报错:RCTAppDelegate.h未找到

解决React Native 0.71.4 iOS构建报错'RCTAppDelegate.h' file not found的问题

以下是针对你的场景(使用AppDelegate.m而非.mm文件)的具体解决方案:

  • 修正AppDelegate.m的继承和导入
    打开你的AppDelegate.m文件,确保头部导入和类继承符合RN 0.71的要求:

    #import <UIKit/UIKit.h>
    #import <React/RCTAppDelegate.h>
    
    @interface AppDelegate : RCTAppDelegate
    
    @property (nonatomic, strong) UIWindow *window;
    
    @end
    

    在实现部分,调整didFinishLaunchingWithOptions方法,调用父类实现:

    @implementation AppDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
      self.moduleName = @"你的应用名称"; // 替换为实际的项目名称
      // 保留你的自定义配置(如推送、第三方库初始化等)
      return [super application:application didFinishLaunchingWithOptions:launchOptions];
    }
    
    // 保留其他必要的代理方法(如url处理、生命周期方法等)
    
    @end
    
  • 检查Xcode的Header Search Paths配置

    1. 打开Xcode,进入项目target的Build Settings标签页
    2. 搜索Header Search Paths,确保包含$(inherited)(这会自动导入pod管理的依赖头文件)
    3. 如果仍有问题,手动添加${PODS_ROOT}/Headers/Public/React-Core,设置为non-recursive
  • 彻底清理缓存并重新构建

    1. 终端执行:cd ios && pod deintegrate && rm -rf Podfile.lock && pod install
    2. 在Xcode中按下Cmd+Shift+K清理当前build,再按下Cmd+Option+Shift+K彻底清理build文件夹
    3. 删除Xcode的DerivedData:打开Xcode的Preferences -> Locations,点击DerivedData路径旁的箭头,删除对应项目的文件夹
  • 验证依赖安装完整性
    检查ios/Pods/Headers/Public/React-Core/目录下是否存在RCTAppDelegate.h文件,如果不存在,说明pod安装不完整,重新执行pod install,确保终端没有报错

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 10:02:17