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

执行pod install时全项目触发Podfile及RNGestureHandler.podspec报错求助

解决pod install时出现undefined method 'exists?' for File:Class报错

问题原因

brew update升级了Ruby版本(Ruby 3.2及以上移除了File.exists?方法,官方替换为File.exist?),而你项目里的react-native-gesture-handler旧版podspec仍在使用已废弃的File.exists?,导致执行pod install时触发报错。

解决方法

方法一:临时修改podspec文件(快速解决当前项目)

  • 找到报错的文件路径:/Users/robajz/Projects/shop8-mobile-app/node_modules/react-native-gesture-handler/RNGestureHandler.podspec
  • 打开文件,将第5行的File.exists?替换为File.exist?
  • 重新在ios目录执行:
pod install

方法二:升级react-native-gesture-handler(长期根治)

新版本的react-native-gesture-handler已经修复了Ruby 3.2+的兼容性问题,直接升级即可:

# npm用户
npm install react-native-gesture-handler@latest

# yarn用户
yarn add react-native-gesture-handler@latest

升级完成后,重新执行pod install。

方法三:降级Ruby版本(适合不想升级依赖的场景)

如果不想修改依赖,可以把Ruby降级到3.1及以下版本(比如用rbenv管理):

# 安装Ruby 3.1.4
rbenv install 3.1.4
# 设置当前项目使用该版本
rbenv local 3.1.4

切换版本后,重新执行pod install。


内容的提问来源于stack exchange,提问作者Robert Kaločai

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 02:51:57