pod install 在Mac M1芯片下报错的解决方案

截屏2021-10-30 09.55.50.png

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.4%2Flib%2Fffi_c.bundle%2C+0x0009%29%3A+could+not+use+%27%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.4%2Flib%2Fffi_c.bundle%27+because+it+is+not+a+compatible+arch+-+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.4%2Flib%2Fffi_c.bundle&type=Issues

If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods...

  • pod trunk push issue
    https://github.com/CocoaPods/CocoaPods/issues/10994 [closed] [14 comments]
    a week ago

  • Pod Install Failed on M1
    https://github.com/CocoaPods/CocoaPods/issues/10953 [closed] [5 comments]
    3 weeks ago

  • Update cloud_firestore issue
    https://github.com/CocoaPods/CocoaPods/issues/10923 [closed] [8 comments]
    a week ago

and 1 more at:
https://github.com/cocoapods/cocoapods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.4%2Flib%2Fffi_c.bundle%2C%200x0009%29%3A%20could%20not%20use%20%27%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.4%2Flib%2Fffi_c.bundle%27%20because%20it%20is%20not%20a%20compatible%20arch%20-%20%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.4%2Flib%2Fffi_c.bundle&type=Issues&utf8=✓

这里大致是ffi的问题,这是一个兼容性问题,关于此问题 github有相关的issue,目前是开放状态。尚未有最终的结局方案,但我相信,后面肯定是能解决的。
只是现在不处理这个问题,是无法使用cocopods的。所以,下面的这个是临时解决方案。后续ffi肯定会从代码层面适配Apple的M1芯片。

目前的解决方案是这样的。

第一步:
首先移除 ffi

sudo gem uninstall ffi

第二步:
在访达中找到终端,右键显示简介,使用Rostta打开。(需要注意的是使用完Cocoapods之后,还需要把Rosetta再调回来)


截屏2021-10-30 09.59.29.png

第三步:
安装ffi

sudo gem install ffi

完成之后,就可以执行pod install 命令了。

如果还报如以下两图的错误:


企业微信截图_e7920c69-f6fb-4b0f-9e74-218954ad44a3.png

这两图之间还打印了很多内容,没有截取


企业微信截图_5909d94b-f6b8-48bf-9c40-7358d55893aa.png

解决方法:执行2条指令

1、sudo arch -x86_64 gem install ffi

打印:
Building native extensions. This could take a while...
Successfully installed ffi-1.15.4
Parsing documentation for ffi-1.15.4
Done installing documentation for ffi after 3 seconds
1 gem installed

再执行:

2、arch -x86_64 pod install

就好了

你可能感兴趣的:(pod install 在Mac M1芯片下报错的解决方案)