无法在 Macbook Air M1 中安装 cocoapods,并且每次创建 flutter 项目时都会丢失 pod 文件

Rag*_*tan 2 cocoapods flutter podfile

当我创建任何 flutter 项目 cocoapods 时,我收到错误。

[警告:CocoaPods 未安装。跳过 Pod 安装。CocoaPods 用于检索 iOS 和 macOS 平台端的插件代码,该代码响应您在 Dart 端的插件使用情况。如果没有 CocoaPods,插件将无法在 iOS 或 macOS 上运行。有关更多信息,请参阅 https://flutter.dev/platform-plugins 要安装,请参阅 https://guides.cocoapods.org/using/getting-started.html#installation 了解说明。

CocoaPods 未安装或未处于有效状态。在 iPhone 13 上启动应用程序时出错。]

当我输入此命令 {gem install cocoapods} 时,我看到此错误 [ /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions /2.6/usr/lib/ruby/2.6.0 -r ./siteconf20211126-3876-kzgsqu.rb extconf.rb *** extconf.rb 失败 *** 由于某种原因无法创建 Makefile,可能缺少必要的库和/或标题。检查 mkmf.log 文件以获取更多详细信息。您可能需要配置选项。

提供的配置选项: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib -- without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME) --with-ffi_c-dir --without-ffi_c-dir --with-ffi_c-包含 --without-ffi_c-include=${ffi_c-dir}/include --with-ffi_c-lib --without-ffi_c-lib=${ffi_c-dir}/lib --enable-system-libffi --disable -system-libffi --with-libffi-config --without-libffi-config --with-pkg-config --without-pkg-config /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib /ruby/2.6.0/mkmf.rb:467 try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:546:in :位于 /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:93 中的 try_link0' 块中:在mktmpdir' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:543:in /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:570:在try_link' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:672:in try_ldflags' 中的 try_link0' 中,从 /System/Library/Frameworks/Ruby.framework/ Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1832:in pkg_config' from extconf.rb:9:in system_libffi_usable?' 来自 extconf.rb:42:in `'

要了解此扩展无法编译的原因,请检查可在此处找到的 mkmf.log:

/Users/raghib/.gem/ruby/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.15.4/mkmf.log

extconf 失败,退出代码 1

Gem 文件将保留安装在 /Users/raghib/.gem/ruby/2.6.0/gems/ffi-1.15.4 中以供检查。]

小智 11

首先完全卸载cocoapods:

sudo gem uninstall cocoapods
sudo gem uninstall cocoapods-core
sudo gem uninstall cocoapods-downloader
Run Code Online (Sandbox Code Playgroud)

然后安装brew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Run Code Online (Sandbox Code Playgroud)

然后安装Cocoapods:

brew install cocoapods
Run Code Online (Sandbox Code Playgroud)