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

升级React Native至0.72.6后Podfile出现config未定义错误

解决React Native 0.72.6升级后pod install报错undefined local variable or method 'config'的方案

问题根源

报错来自Podfile的post_install代码块中未正确定义或引用config变量,React Native 0.70+版本的Podfile结构发生变化,旧版本的配置写法不再适配。

具体修改步骤

  1. 定位问题代码:打开ios/Podfile,找到第109行所在的post_install代码块。
  2. 修正参数传递:
    • 确保post_install块接收installer参数,写法应为:
      post_install do |installer|
        # 你的配置代码
      end
      
    • 若遍历build_configurations时未传入config变量,补上参数定义:
      错误写法:
      target.build_configurations.each do
        config.build_settings[...] = ...
      end
      
      修正为:
      target.build_configurations.each do |config|
        config.build_settings[...] = ...
      end
      
  3. 添加RN必需的后置处理:在post_install块末尾添加React Native 0.70+要求的配置处理:
    react_native_post_install(installer)
    

示例修正后的post_install块

post_install do |installer|
  # 自定义配置示例:修改部署目标版本
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
  # RN 0.70+必需的后置处理
  react_native_post_install(installer)
end

验证操作

修改完成后执行以下命令重新安装依赖:

pod install --repo-update

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 00:25:15