美文网首页
cocoapods更新坑点以及解决方案

cocoapods更新坑点以及解决方案

作者: 崇山峻岭 | 来源:发表于2024-09-03 11:17 被阅读0次

  1. 使用gem更新报错:
sudo gem install cocoapods


ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.



出现这个错误是因为你没有写权限去安装gem到/usr/bin目录。在新的macOS系统中,由于系统完整性保护(SIP),通常不允许用户直接修改/usr/bin目录下的内容。

  • 解决方案:

    • 修改pod存储位置, 从系统/usr/bin 改到 user目录下

      gem install --user-install cocoapods   //不推荐这个
      

      如果使用了--user-install选项,可能需要将Ruby Gems的可执行文件路径添加到你的shell配置文件(比如.bash_profile, .zshrc, 等)中。例如:export PATH=PATH:(ruby -e 'puts Gem.user_dir')/bin

  1. 使用Homebrew安装CocoaPods

    brew install cocoapods
    
    可能遇到如下问题
    Error: The `brew link` step did not complete successfully
    The formula built, but is not symlinked into /usr/local
    Could not symlink bin/pod
    

    这个错误信息表明Homebrew在尝试将CocoaPods的可执行文件pod链接到/usr/local/bin目录时遇到了问题,因为那里已经存在一个名为pod的文件。这可能是由于你之前以其他方式安装过CocoaPods,或者有其他软件包安装了同名的可执行文件。

    两种解决方案

    1. 手动删除cocoapods 不推荐
    2. 命令行强制覆盖 (brew link --overwrite cocoapods)

执行完方案2之后,理论上讲就完成了更新
验证是否是最新

pod --version
1.15.2
// 当前最新版本为 1.15.2  (2024-09-04)

相关文章

网友评论

      本文标题:cocoapods更新坑点以及解决方案

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