美文网首页
关于macOs13安装cocoapods的流程记录

关于macOs13安装cocoapods的流程记录

作者: MM面包 | 来源:发表于2023-08-07 22:05 被阅读0次

    前景提要:

    电脑重装系统辣,导致电脑之前安装的ruby环境以及cocoapods等其他相关环境全都没了,所以都需要重新整了,踩了好多坑,所以打算记录下来,下次可别这么折磨人了,也希望有相同问题的小伙伴少走一些弯路。之前踩坑错误的流程我就不总结了,直接贴从头到脚无痛顺利安装cocoapods的过程!!
    *还有我是重装系统,所以当前系统无之前相关版本,都是重新安装的

    第一步,安装命令行工具

    终端输入:

     xcode-select –install
    

    第二步,安装homebrew

    详参此链接:Mac系统HomeBrew安装过程

    第三步,安装ruby环境

    1.终端执行这句指令:

    brew install ruby
    

    2.如果终端出现以下内容说明安装成功,但是还需要下一步设置路径问题

    截屏2023-08-08 20.53.20.png

    3.下一步配置路径问题,在终端输入以下内容:

    echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
    

    4.然后终端输入以下内容,

    ruby --version
    
    5.可以查看到ruby的版本号就说明安装成功了 截屏2023-08-08 21.01.06.png

    6.然后关闭终端,重启

    第四步,更换ruby为国内镜像

    1.先查看当前系统的ruby环境,在终端输入以下内容

    gem sources -l
    

    2.默认环境是(我没记错的话,因为我的已经是更换过的了)

    *** CURRENT SOURCES ***
    https://rubygems.org

    3.先将系统中默认的ruby环境移除,在终端输入以下内容:

    gem source -r https://rubygems.org
    

    4.然后添加国内镜像,终端继续输入:

    gem source -a https://gems.ruby-china.com
    

    5.然后终端再输入:gem sources -l,出现以下内容就ok了


    截屏2023-08-08 21.48.41.png

    6.终于可以下一步了,累鼠了。。

    第五步,终于可以开始安装cocoapods辣!

    1.终端输入:

    gem install cocoapods --user-install  
    

    2.然后会出现以下内容:

    WARNING: You don't have /Users/你的电脑用户名/.gem/ruby/2.6.0/bin in your PATH,
    gem executables will not run.
    Successfully installed rexml-3.2.6
    Successfully installed nanaimo-0.3.0
    Successfully installed colored2-3.1.2
    Successfully installed claide-1.1.0
    Successfully installed atomos-0.1.3
    Successfully installed xcodeproj-1.22.0
    Successfully installed ruby-macho-2.5.1
    Successfully installed nap-1.1.0
    Successfully installed molinillo-0.8.0
    Successfully installed gh_inspector-1.1.3
    Successfully installed fourflusher-2.3.1
    Successfully installed escape-0.0.4
    Successfully installed cocoapods-try-1.2.0
    Successfully installed netrc-0.11.0
    Successfully installed cocoapods-trunk-1.6.0
    Successfully installed cocoapods-search-1.0.1
    Successfully installed cocoapods-plugins-1.0.0
    Successfully installed cocoapods-downloader-1.6.3
    Successfully installed cocoapods-deintegrate-1.0.5
    Building native extensions. This could take a while...
    Successfully installed ffi-1.15.5
    Successfully installed ethon-0.16.0
    Successfully installed typhoeus-1.4.0
    Successfully installed public_suffix-4.0.7
    Successfully installed fuzzy_match-2.0.4
    Successfully installed concurrent-ruby-1.2.2
    Building native extensions. This could take a while...
    Successfully installed json-2.6.3
    Successfully installed httpclient-2.8.3
    A new major version is available for Algolia! Please now use the https://rubygems.org/gems/algolia gem to get the latest features.
    Successfully installed algoliasearch-1.27.5
    Successfully installed addressable-2.8.5
    Successfully installed zeitwerk-2.6.11
    Successfully installed tzinfo-2.0.6
    Successfully installed minitest-5.19.0
    Successfully installed i18n-1.14.1
    Successfully installed activesupport-6.1.7.4
    Successfully installed cocoapods-core-1.12.1
    Successfully installed cocoapods-1.12.1
    Parsing documentation for rexml-3.2.6
    Installing ri documentation for rexml-3.2.6
    Parsing documentation for nanaimo-0.3.0
    Installing ri documentation for nanaimo-0.3.0
    Parsing documentation for colored2-3.1.2
    Installing ri documentation for colored2-3.1.2
    Parsing documentation for claide-1.1.0
    Installing ri documentation for claide-1.1.0
    Parsing documentation for atomos-0.1.3
    Installing ri documentation for atomos-0.1.3
    Parsing documentation for xcodeproj-1.22.0
    Installing ri documentation for xcodeproj-1.22.0
    Parsing documentation for ruby-macho-2.5.1
    Installing ri documentation for ruby-macho-2.5.1
    Parsing documentation for nap-1.1.0
    Installing ri documentation for nap-1.1.0
    Parsing documentation for molinillo-0.8.0
    Installing ri documentation for molinillo-0.8.0
    Parsing documentation for gh_inspector-1.1.3
    Installing ri documentation for gh_inspector-1.1.3
    Parsing documentation for fourflusher-2.3.1
    Installing ri documentation for fourflusher-2.3.1
    Parsing documentation for escape-0.0.4
    Installing ri documentation for escape-0.0.4
    Parsing documentation for cocoapods-try-1.2.0
    Installing ri documentation for cocoapods-try-1.2.0
    Parsing documentation for netrc-0.11.0
    Installing ri documentation for netrc-0.11.0
    Parsing documentation for cocoapods-trunk-1.6.0
    Installing ri documentation for cocoapods-trunk-1.6.0
    Parsing documentation for cocoapods-search-1.0.1
    Installing ri documentation for cocoapods-search-1.0.1
    Parsing documentation for cocoapods-plugins-1.0.0
    Installing ri documentation for cocoapods-plugins-1.0.0
    Parsing documentation for cocoapods-downloader-1.6.3
    Installing ri documentation for cocoapods-downloader-1.6.3
    Parsing documentation for cocoapods-deintegrate-1.0.5
    Installing ri documentation for cocoapods-deintegrate-1.0.5
    Parsing documentation for ffi-1.15.5
    Installing ri documentation for ffi-1.15.5
    Parsing documentation for ethon-0.16.0
    Installing ri documentation for ethon-0.16.0
    Parsing documentation for typhoeus-1.4.0
    Installing ri documentation for typhoeus-1.4.0
    Parsing documentation for public_suffix-4.0.7
    Installing ri documentation for public_suffix-4.0.7
    Parsing documentation for fuzzy_match-2.0.4
    Installing ri documentation for fuzzy_match-2.0.4
    Parsing documentation for concurrent-ruby-1.2.2
    Installing ri documentation for concurrent-ruby-1.2.2
    Parsing documentation for json-2.6.3
    Installing ri documentation for json-2.6.3
    Parsing documentation for httpclient-2.8.3
    Installing ri documentation for httpclient-2.8.3
    Parsing documentation for algoliasearch-1.27.5
    Installing ri documentation for algoliasearch-1.27.5
    Parsing documentation for addressable-2.8.5
    Installing ri documentation for addressable-2.8.5
    Parsing documentation for zeitwerk-2.6.11
    Installing ri documentation for zeitwerk-2.6.11
    Parsing documentation for tzinfo-2.0.6
    Installing ri documentation for tzinfo-2.0.6
    Parsing documentation for minitest-5.19.0
    Installing ri documentation for minitest-5.19.0
    Parsing documentation for i18n-1.14.1
    Installing ri documentation for i18n-1.14.1
    Parsing documentation for activesupport-6.1.7.4
    Installing ri documentation for activesupport-6.1.7.4
    Parsing documentation for cocoapods-core-1.12.1
    Installing ri documentation for cocoapods-core-1.12.1
    Parsing documentation for cocoapods-1.12.1
    Installing ri documentation for cocoapods-1.12.1
    Done installing documentation for rexml, nanaimo, colored2, claide, atomos, xcodeproj, ruby-macho, nap, molinillo, gh_inspector, fourflusher, escape, cocoapods-try, netrc, cocoapods-trunk, cocoapods-search, cocoapods-plugins, cocoapods-downloader, cocoapods-deintegrate, ffi, ethon, typhoeus, public_suffix, fuzzy_match, concurrent-ruby, json, httpclient, algoliasearch, addressable, zeitwerk, tzinfo, minitest, i18n, activesupport, cocoapods-core, cocoapods after 47 seconds
    36 gems installed

    3.此步骤虽然安装成功了cocoapods,但是pod命令是不好用的,如果不信叛逆的你可以试着输入 pod --version试试,会不会出现这个,我就是这一步排雷好久啊

    sh: command not found: pod

    4.为了让pod听从指挥,请在终端输入以下路径配置:

    PATH="`ruby -e 'puts Gem.user_dir'`/bin:$PATH"
    

    5.然后再在终端输入:

    gem install cocoapods --user-install  
    
    截屏2023-08-08 22.01.26.png

    大功已成!!!
    6.可以试试输入启动"pod setup"命令,会出现绿油油的一行小字,真清爽舒适的颜色!!


    截屏2023-08-08 22.03.19.png

    接下来就可以想干嘛干嘛辣,管理你得第三方库辣
    如果铁铁们还有遇到其他的问题留言大家一起🍑

    **注意
    在项目中pod install 之后 会出现以下问题

    [!] CDN: trunk URL couldn‘t be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/

    解决思路详参(亲测有效):在podfile文件中添加指定的spec repo源

    相关文章

      网友评论

          本文标题:关于macOs13安装cocoapods的流程记录

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