Equipment: MacBook2023 M2Pro chip
cocoapods version: 1.9.3
Related commands to install cocoapods on mac
(My computer needs to be installed to version 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. After the installation is complete, execute `pod --version` to check whether the installation is successful, and the result is an error:
~ 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. Judging from the error report, the arm64 version of ffi needs to be included, so execute the following command:
$ arch -arm64 sudo gem install ffi