flutter与iOS混编的项目,之前一直pod install 正常,有一天想研究下vscode编写插件,就安装了npm,结果再执行pod install 报错了。
在iOS工程目录下执行pod install 报错:
Invalid `Podfile` file: undefined method `exists?' for File:Class
在flutter工程目录下执行flutter build ios,报错:
CocoaPods' output:
↳
[!] Invalid `Podfile` file: undefined method `exists?' for File:Class.
# from /Users/admin/Desktop/flutter_plugin/.ios/Podfile:31
# -------------------------------------------
# use_frameworks!
> flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
#
# -------------------------------------------
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-core-1.11.3/lib/coco
apods-core/podfile.rb:335:in `rescue in block in from_ruby'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-core-1.11.3/lib/coco
apods-core/podfile.rb:329:in `block in from_ruby'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-core-1.11.3/lib/coco
apods-core/podfile.rb:50:in `instance_eval'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-core-1.11.3/lib/coco
apods-core/podfile.rb:50:in `initialize'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-core-1.11.3/lib/coco
apods-core/podfile.rb:327:in `new'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-core-1.11.3/lib/coco
apods-core/podfile.rb:327:in `from_ruby'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-core-1.11.3/lib/coco
apods-core/podfile.rb:293:in `from_file'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods
/config.rb:205:in `podfile'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods
/command.rb:160:in `verify_podfile_exists!'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods
/command/install.rb:46:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/claide-1.1.0/lib/claide/comman
d.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods
/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/bin/pod:55:in
`<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/bin/pod:25:in `load'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/bin/pod:25:in `<main>'
Error running pod install
解决办法: 删除cocoapod 1.11.3版本,安装1.11.2版本
删除cocoapod.
$ sudo gem uninstall cocoapods -v (移除的版本号)
安装1.11.2
sudo gem install cocoapods -v (要安装的版本号)
重新pod install 解决
删除cocoapod不彻底时,可参考
https://blog.csdn.net/Qyee16/article/details/52055084?locationNum=7&fps=1
网友评论