M1芯片:cocoapods安装后kernel_require.rb:54:in `require‘报错

设备:MacBook2023款 M2Pro芯片

cocoapods版本:1.9.3

  1. mac上安装cocoapods的相关命令

(我的电脑需要安装到1.9.3版本)

//升级cocoapods至最新版本
$ sudo gem install cocoapods -n /usr/local/bin

//升级cocoapods到指定版本  (我的电脑安装到1.9.3版本)
$ sudo gem install cocoapods -v 1.9.3

//卸载之前的旧版本
$ sudo gem uninstall cocoapods -v1.2.1
2. 安装完成后,执行`pod --version`检查是否安装成功,结果报错:
~ pod --version
/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.5/lib/ffi_c.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle' (no such file), '/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle (LoadError)
3. 从报错来看,需要包含arm64版本的ffi,于是执行如下命令:
$ arch -arm64 sudo gem install ffi
4. 再次执行pod命令,搞定。

猜你喜欢

转载自blog.csdn.net/enuola/article/details/129283794