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

如何永久更新React Codegen的iOS Deployment Target版本?

永久设置React-Codegen的Deployment Target为12.0

React-Codegen的Deployment Target在pod install后被重置,是因为它的podspec文件里默认配置了iOS 11.0作为最低部署版本。要永久修改这个值,有两种可靠的方案:

方案一:使用Podfile的post_install钩子(推荐)

这是最通用的方案,不需要修改node_modules里的文件,适合团队协作场景:

  1. 打开项目根目录下的Podfile
  2. 在文件末尾添加以下脚本:
post_install do |installer|
  installer.pods_project.targets.each do |target|
    # 定位到React-Codegen目标
    next unless target.name == "React-Codegen"
    
    target.build_configurations.each do |config|
      # 修改所有构建配置的最低部署版本为12.0
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
end
  1. 保存文件后,执行pod install,之后每次运行pod install或pod update时,脚本都会自动将React-Codegen的Deployment Target设置为12.0。

方案二:使用patch-package打补丁

如果你更倾向于直接修改React-Codegen的源配置文件,可以用patch-package生成持久化补丁:

  1. 找到node_modules/react-native/packages/react-codegen/react-codegen.podspec文件,将其中的:
s.platform = :ios, '11.0'

修改为:

s.platform = :ios, '12.0'
  1. 安装patch-package依赖:
npm install patch-package --save-dev
  1. 生成补丁文件:
npx patch-package react-native
  1. 之后每次执行npm install或yarn install时,补丁会自动应用到react-native包,pod install时就会使用修改后的部署版本配置。

两种方案都能解决你的问题,根据自己的项目场景选择即可。

内容的提问来源于stack exchange,提问作者Gaëtan Fauconnier

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 06:05:03