Invalid `Podfile` file: undefined method `exists?‘ for File:Class解决方案

mac系统重装之后运行之前的Flutter项目,报下面的错误:

当时的Mac系统为12.5.1

Flutter的版本号为3.0.5

ruby的版本号为3.2.0

[!] Invalid `Podfile` file: undefined method `exists?' for File:Class

  return [] unless File.exists? file_path
                       ^^^^^^^^
Did you mean?  exist?.

 #  from /Users/project/new1/ios/Podfile:38
 #  -------------------------------------------
 #    use_modular_headers!
 >    flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
 #  end
 #  -------------------------------------------

经过排查:是ruby版本的问题,Flutter3.0.5引用了ruby中的一个类,这个类在3.2之后的版本中发生了变化。

解决方案:把ruby的版本号降为3.1.2.重新安装cocoapods

猜你喜欢

转载自blog.csdn.net/ZCC361571217/article/details/126469358