我正在开发适用于 Android 和 iOS 的 Flutter 应用程序。该应用程序在 Android 模拟器上处于稳定的开发状态,因此我想尝试在 iOS 模拟器上运行它。 Macos 上的 Flutter 安装过程需要安装 Cocoapods。在尝试使用Macos安装Ruby并遇到权限错误后,我决定尝试asdf、最新版本的Ruby(Ruby 3.0.3p157(2021-11-24修订版3fb7d2cadc)[x86_64-darwin21])和Cocoapods(1.11) .2).看起来安装成功,但是运行 pod 会出现以下错误:
加载插件时出错
cocoapods-plugins-1.0.0
。
NoMethodError - 未定义的方法
activate' for #<Gem::StubSpecification:0x00007f963819f4f8 @extension_dir=nil, @full_gem_path="/Users/xyz/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/cocoapods-plugins-1.0.0", @gem_dir=nil, @ignored=nil, @loaded_from="/Users/kevin/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/specifications/cocoapods-plugins-1.0.0.gemspec", @data=#<Gem::StubSpecification::StubLine:0x00007f9638194850 @name="cocoapods-plugins", @version=#<Gem::Version "1.0.0">, @platform="ruby", @extensions=[], @full_name="cocoapods-plugins-1.0.0", @require_paths=["lib"]>, @name=nil, @spec=#<Gem::Specification:0x00007f96381cc278 @extension_dir=nil, @full_gem_path="/Users/kevin/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/cocoapods-plugins-1.0.0", @gem_dir=nil, @ignored=nil, @bin_dir=nil, @cache_dir=nil, @cache_file=nil, @doc_dir=nil, @ri_dir=nil, @spec_dir=nil, @spec_file=nil, @gems_dir="/Users/kevin/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems", @base_dir="/Users/kevin/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0", @loaded=true, @activated=true, @loaded_from="/Users/kevin/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/specifications/cocoapods-plugins-1.0.0.gemspec", @original_platform=nil, @installed_by_version=#<Gem::Version "3.3.2">, @autorequire=nil, @date=2016-05-10 00:00:00 UTC, @description=" This CocoaPods plugin shows information about all available CocoaPods plugins\n (yes, this is very meta!).\n This CP plugin adds the \"pod plugins\" command to CocoaPods so that you can list\n all plugins (registered in the reference JSON hosted at CocoaPods/cocoapods-plugins)\n", @email=nil, @homepage="https://github.com/cocoapods/cocoapods-plugins", @name="cocoapods-plugins", @post_install_message=nil, @signing_key=nil, @summary="CocoaPods plugin which shows info about available CocoaPods plugins.", @version=#<Gem::Version "1.0.0">, @authors=["David Grandinetti", "Olivier Halligon"], @bindir="bin", @cert_chain=[], @dependencies=[<Gem::Dependency type=:runtime name="nap" requirements=">= 0">, <Gem::Dependency type=:development name="bundler" requirements="~> 1.3">, <Gem::Dependency type=:development name="rake" requirements=">= 0">], @executables=[], @extensions=[], @extra_rdoc_files=[], @files=[], @licenses=["MIT"], @metadata={}, @platform="ruby", @rdoc_options=[], @require_paths=["lib"], @required_ruby_version=#<Gem::Requirement:0x00007f96381d7b28 @requirements=[[">=", #<Gem::Version "2.0.0">]]>, @required_rubygems_version=#<Gem::Requirement:0x00007f96381d7ee8 @requirements=[[">=", #<Gem::Version "0">]]>, @requirements=[], @rubygems_version="3.3.2", @specification_version=4, @test_files=[], @new_platform="ruby", @full_name="cocoapods-plugins-1.0.0", @full_require_paths=["/Users/kevin/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/cocoapods-plugins-1.0.0/lib"] cocoapods-plugins-1.0.0>, @base_dir="/Users/kevin/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0", @gems_dir="/Users/kevin/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems", @default_gem=false, @activated=true> Did you mean? activated? /Users/xyz/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/claide-1.0.3/lib/claide/command/plugin_manager.rb:93:in
safe_activate_and_require'
/Users/xyz/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/claide-1.0.3/lib/claide/command/plugin_manager.rb:31:in block in load_plugins' /Users/xyz/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/claide-1.0.3/lib/claide/command/plugin_manager.rb:30:in
地图'
/Users/xyz/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/claide-1.0.3/lib/claide/command/plugin_manager.rb:30:in load_plugins' /Users/xyz/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/claide-1.0.3/lib/claide/command.rb:326:in
阻止运行'
/Users/xyz/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/claide-1.0.3/lib/claide/command.rb:325:in each' /Users/xyz/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/claide-1.0.3/lib/claide/command.rb:325:in
运行'
/Users/xyz/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:52:in run' /Users/xyz/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/cocoapods-1.11.2/bin/pod:55:in
load' /Users/xyz/.asdf/installs/ruby/3.0.3/bin/pod:25:in
'
我不需要修复。我只是想知道 Ruby 和 Cocoapods 的版本是否兼容,并且可以让我在 Macos 上开发 Flutter 应用程序方面取得进展。
我发布上述问题后,其他人也遇到了与此处报告的相同的问题:https://github.com/CocoaPods/CocoaPods/issues/11134
该问题的解决方法是使用 Ruby 2.7.5。安装该版本后,我发现 Cocoapods 1.11.2 与 Ruby 2.7.5 兼容。