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

Xcode 13.1编译React Native 0.64.0提示yoga/yoga.h文件找不到如何解决

针对Xcode 13.1 + React Native 0.64 环境下 yoga/yoga.h file not found 报错的解决方案
  • 先清理全链路缓存和旧构建产物
    完全退出Xcode后,在项目根目录依次执行以下命令:
    rm -rf ~/Library/Developer/Xcode/DerivedData
    rm -rf ios/build
    rm -rf node_modules
    rm package-lock.json yarn.lock
    npm install
    cd ios && pod deintegrate && rm Podfile.lock && pod install
    
    执行完成后禁止用.xcodeproj文件打开项目,必须使用ios/[你的项目名].xcworkspace启动项目再执行构建。
  • 修正Podfile配置
    确认你的Podfile中添加了兼容配置,如果你开启了use_frameworks!,必须在Podfile末尾添加以下post_install钩子修正头文件路径和版本兼容问题:
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        # 修正Yoga头文件搜索路径
        if target.name == "Yoga"
          target.build_configurations.each do |config|
            config.build_settings['HEADER_SEARCH_PATHS'] ||= ['$(inherited)']
          end
        end
        # 适配Xcode 13对RN 0.64的编译兼容要求
        if target.name == "React-Core"
          target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
          end
        end
      end
    end
    
    修改完成后重新执行pod install再尝试构建。
  • 手动添加头文件搜索路径
    如以上操作无效,打开Xcode的项目设置,选中你的主target,在「Build Settings」中找到「Header Search Paths」配置项,添加以下路径并设置为recursive:
    $(PODS_ROOT)/Yoga/yoga
    
  • 排除不兼容架构
    Xcode 13默认支持arm64模拟器架构,但RN 0.64对该架构的兼容存在缺陷,你可以在主target和Pods项目的Build Settings的「Excluded Architectures」配置项中,针对Debug模式添加arm64,避免模拟器构建时触发架构兼容问题。

内容的提问来源于stack exchange,提问作者Sourazou Soury Bountoulgou

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.24 15:36:05