Cocoapods 在 MacBook Pro M1 Apple Silicon Mac 上安装失败

问题描述

我已经尝试在“Rossetta”模式下运行终端时进行安装。但即便如此,安装还是失败了。

我使用的命令:sudo gem install cocoapods 也尝试安装 Homebrew,但我遇到了同样的错误。

我得到的错误如下:

ERROR:  Loading command: install (LoadError)
dlsym(0x7fbc673521d0,Init_date_core): symbol not found - /Library/Ruby/Gems/2.6.0/gems/date-3.1.1/lib/date_core.bundle
ERROR:  While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass

解决方法

您可以转到此 GitHub issue 以获取解决方法。下面的命令似乎适用于 M1 机器上的某些人安装 Cocoapods。

arch -x86_64 sudo gem 安装 cocoapods

,

当我通过 sudo gem install cocoapods 安装 cocoapods 时,我也遇到了同样的问题。我使用的是带有 Apple Silicon (M1) 芯片的 MacBook Pro。为了解决这个问题,我不得不使用 sudo gem uninstall cocoapods 卸载 cocoapods 并使用以下命令重新安装:

arch -arm64 brew install cocoapods

,

我找到了解决方案,伙计。当我谷歌这个问题时,你应该得到同样的答案:

$ sudo arch -x86_64 gem install ffi

$ arch -x86_64 pod install

但这是错误的!!!检查错误日志

/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in ‘需要’: dlopen(/Library/Ruby/Gems/2.6.0/gems/date-3.1.1/lib/date_core.bundle,9): 没有找到合适的图片。确实找到了:(LoadError) /Library/Ruby/Gems/2.6.0/gems/date-3.1.1/lib/date_core.bundle: mach-o,但错误的架构 /Library/Ruby/Gems/2.6.0/gems/date-3.1.1/lib/date_core.bundle: mach-o,但错误的架构 - /Library/Ruby/Gems/2.6.0/gems/date-3.1.1/lib/date_core.bundle

这意味着您需要 gem 的日期。所以:

sudo gem install date

大功告成!!

您可能还会看到此错误:

dlopen(/Library/Ruby/Gems/2.6.0/gems/bigdecimal-3.0.2/lib/bigdecimal.bundle,9): no suitable image found. Did find: (LoadError)
/Library/Ruby/Gems/2.6.0/gems/bigdecimal-3.0.2/lib/bigdecimal.bundle: mach-o,but wrong architecture
/Library/Ruby/Gems/2.6.0/gems/bigdecimal-3.0.2/lib/bigdecimal.bundle: mach-o,but wrong architecture - /Library/Ruby/Gems/2.6.0/gems/bigdecimal-3.0.2/lib/bigdecimal.bundle

所以,只是:

sudo gem install bigdecimal

大功告成!!!

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...