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

React Native iOS构建失败求助:RCT-Folly编译错误及脚本警告

React Native iOS构建失败(RCT-Folly SysUio.cpp编译错误)解决方案

核心问题处理:RCT-Folly编译失败

方案1:调整iOS部署目标版本

  • 打开Xcode,进入项目Build Settings,搜索iOS Deployment Target,将版本设置为12.4及以上(RCT-Folly对低版本iOS兼容性较差)
  • 同步修改Podfile中的平台版本,确保和项目一致:
    platform :ios, '12.4'
    
    修改后重新执行pod install

方案2:添加RCT-Folly编译兼容参数

  • 在Xcode的Pods项目中找到RCT-Folly目标,进入Build Settings
  • 搜索Other C++ Flags,添加-Wno-error=deprecated-declarations和-Wno-error=unused-variable
  • 也可以在Podfile中添加配置,避免每次pod install重置参数:
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        if target.name == "RCT-Folly"
          target.build_configurations.each do |config|
            config.build_settings["OTHER_CPLUSPLUSFLAGS"] = "-Wno-error=deprecated-declarations -Wno-error=unused-variable"
          end
        end
      end
    end
    
    执行pod install后重新构建

方案3:锁定RCT-Folly版本(针对RN版本兼容问题)

  • 在Podfile中指定RCT-Folly的兼容版本(例如RN 0.68+可指定2021.07.22.00版本):
    pod 'RCT-Folly', '2021.07.22.00', :modular_headers => true
    
    执行pod install

优化脚本阶段警告(解决重复执行问题)

三个脚本警告是因为未指定输出文件,可手动添加输出路径优化构建缓存:

  1. Start Packager脚本:
    • 进入Xcode项目目标的Build Phases -> Start Packager
    • 点击Output Files,添加$(DERIVED_FILE_DIR)/packager-started.txt
  2. Bundle React Native code and images脚本:
    • 添加输出文件$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)和$(DERIVED_FILE_DIR)/react-native-bundle.js
  3. [CP-User] Config codegen脚本:
    • 添加输出文件$(DERIVED_FILE_DIR)/codegen-config.json

终极清理步骤(以上方案无效时尝试)

  • 执行以下命令彻底清理缓存:
    rm -rf node_modules && npm install
    cd ios && rm -rf Pods Podfile.lock *.xcworkspace
    pod deintegrate && pod install
    cd .. && watchman watch-del-all
    rm -rf $TMPDIR/react-native-packager-*
    rm -rf $TMPDIR/metro-bundler-cache-*
    
  • 打开Xcode,执行Product -> Clean Build Folder(快捷键Cmd+Shift+K),再重新构建

内容的提问来源于stack exchange,提问作者Jay-C0de

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 07:00:57