美文网首页ios
Mac M1 安装cocoapods失败的解决办法 (pod i

Mac M1 安装cocoapods失败的解决办法 (pod i

作者: topws1 | 来源:发表于2022-06-17 20:34 被阅读0次

    M1 芯片在安装 cocoapods 时会提示不兼容的错误,会提示需要安装 ffi。
    这时可以通过 sudo arch -x86_64 gem install ffi 命令来安装 ffi

    假如在执行 上述命令出错提示:arch: posix_spawnp: gem: Bad CPU type in executable 时,需要再把旧的 cocoapods 移除重装。

    执行步骤如下:
    1、移除旧的 ruby brew uninstall ruby --force
    2、移除旧的 cocoapods, 这里需要把所有的 components 都移除掉,可以先执行 gem list --local | grep cocoapods 来查看所有的 component,然后挨个移除。
    示例如下:
    sudo gem uninstall cocoapods
    sudo gem uninstall cocoapods-core
    sudo gem uninstall cocoapods-downloader
    ...
    3、移除成功再去执行 如下两条重装的命令:
    sudo arch -x86_64 gem install ffi
    sudo arch -x86_64 gem install cocoapods

    成功后再次运行 pod install 即可正常使用

    Note:如果以上解决方案仍然失败,需要考虑终端的打开方式,改成 使用 Rosetta 打开。(在应用程序-实用工具 里面找到 终端,右键显示简介)

    相关文章

      网友评论

        本文标题:Mac M1 安装cocoapods失败的解决办法 (pod i

        本文链接:https://www.haomeiwen.com/subject/ulphvrtx.html