Flutter 'CocoaPods Error'和'Error running pod install'

首先呢,报错如下:

Error output from CocoaPods:
↳

    [!] Automatically assigning platform `iOS` with version `9.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle, 9): no suitable image found.  Did find: (LoadError)
        /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle: mach-o, but wrong architecture
        /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle: mach-o, but wrong architecture - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle

……
Error running pod install

项目根目录中执行以下命令:

sudo gem install ffi

然后进入到Podfile文件所在目录(也就是项目下的ios目录),执行以下命令:

arch -x86_64 pod install or pod install
或者是
pod install

如果还是报错,并且是m1芯片,可以参考如下命令

1、先卸载Ruby
brew uninstall ruby --force

2、卸载可能已经安装但没成功安装的CocoaPods
sudo gem uninstall cocoapods
sudo gem uninstall cocoapods-core
sudo gem uninstall cocoapods-downloader

3、重新安装ffi和cocoapods
sudo arch -x86_64 gem install ffi
sudo arch -x86_64 gem install cocoapods

4、最后仍然在Podfile文件所在的目录(项目的ios目录),运行
arch -x86_64 pod install

此时已经安装成功,再次启动项目,“Running pod install...”这一步已经可以顺利通过了。

整理不易,如果有帮助谢谢点赞支持。

你可能感兴趣的:(Flutter 'CocoaPods Error'和'Error running pod install')