美文网首页
MacOS M2芯片 安装cocoapod 教程

MacOS M2芯片 安装cocoapod 教程

作者: w冷兔w | 来源:发表于2024-07-08 17:47 被阅读0次

1.编辑host

为了解决 DNS污染 github被错误解析


sudo vi /etc/hosts

在host添加:


185.199.108.133 raw.githubusercontent.com

185.199.109.133 raw.githubusercontent.com

185.199.110.133 raw.githubusercontent.com

185.199.111.133 raw.githubusercontent.com

也可通过

通过https://www.ipaddress.com/ 获得raw.githubusercontent.com 的 IP 地址

2.安装 ** Homebrew**

去网址:https://brew.sh/zh-cn/ 安装

执行命令安装:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

安装完成

Warning: /opt/homebrew/bin is not in your PATH.

  Instructions on how to configure your shell for Homebrew

  can be found in the 'Next steps' section below.

==> Installation successful!

复制粘贴“Next Step”提示的命令行,添加路径

==> Next steps:

- Run these two commands in your terminal to add Homebrew to your PATH:

    (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/leahchen/.zprofile

    eval "$(/opt/homebrew/bin/brew shellenv)"

在 Mac HD opt目录下

检测是否安装homebrew

brew -v

3.安装ruby

brew install ruby

配置环境变量

echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zprofile

检查:ruby

ruby -v

4.安装 rvm

\curl -sSL https://get.rvm.io | bash -s stable --ruby

查看rvm版本

rvm -v

查看可安装的ruby版本列表

rvm list known

rvm install ruby-3.0.0

5.安装 cocoapod

sudo gem install -n /usr/local/bin cocoapods

报错

Error installing cocoapods:

The last version of drb (>= 0) to support your Ruby & RubyGems was 2.0.6\. Try installing it with `gem install drb -v 2.0.6` and then running the current command again

drb requires Ruby version >= 2.7.0\. The current ruby version is 2.6.10.210.

解决:

sudo gem install drb -v 2.0.6

报错: M2芯片的问题

Error running '__rvm_make -j8',

please read /Users/kevin_wang/.rvm/log/1720421003_ruby-3.0.0/make.log

There has been an error while running make. Halting the installation.

解决: 依次执行

brew uninstall --ignore-dependencies openssl@3

rm -rf /usr/local/etc/openssl@1.1

brew reinstall openssl@1.1

rvm install 3.0.0

再次: 应该可以成功了

sudo gem install -n /usr/local/bin cocoapods

6.安装本地库(目的:下载pod第三方索引文件) (太慢了)

git clone https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/master

解决:首次CocoaPods拉取repos过慢问题

https://github.com/CocoaPods/Specs 下载zip

复制到master.png

复制后:关联Git远端仓库

打开master路径:cd ~/.cocoapods/repos/master

初始化git:git init

关联仓库:git remote add origin https://github.com/CocoaPods/Specs

验证是否成功:

终端输入:pod repo,如果输出信息与我们预期的一致说明没有问题:

名字:master

git地址:https://github.com/CocoaPods/Specs.git

本地路径:/Users/电脑用户名/.cocoapods/repos/master

master

- Type: git (unknown)

- URL:  https://github.com/CocoaPods/Specs

- Path: /Users/kevin_wang/.cocoapods/repos/master

还是报错:

1. undefined method `request' for nil (NoMethodError)

  1. Unable to satisfy the following requirements: (Gem::Molinillo::VersionConflict)

解决:依次来一遍

gem cleanup

brew uninstall cocoapods

sudo gem uninstall cocoapods

sudo gem install cocoapods -n /usr/local/bin

sudo gem install cocoapods-user-defined-build-types

pod install --repo-update

成功!

相关文章

网友评论

      本文标题:MacOS M2芯片 安装cocoapod 教程

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