当前位置: 首页 > news >正文

Mac M2 Pro安装使用Cocoapods

Mac Pro M2安装使用Cocoapods

在新公司要做iOS开发,所以在新电脑上安装Cocoapods

在升级gem,sudo gem update --system,和安装cocoapods时都遇到如下的提示:

ERROR:  While executing gem ... (Errno::EPERM)Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/gem

原因大概是:Apple已内置安装了ruby,不能修改

参考:

  • While executing gem … (Gem::FilePermissionError)

the reason why you are getting that error is because Apple doesn’t allow you to install gems directly into the version of Ruby that came preinstalled on your Mac

其中的一个解决办法就是,可通过安装ruby版本管理器来解决,如chruby或者RVM

安装chruby

参考Install Ruby 3.1 · macOS

brew install ruby-install chruby

安装后按提示,在.zshrc 中写入如下的内容:

source /opt/homebrew/opt/chruby/share/chruby/chruby.sh
source /opt/homebrew/opt/chruby/share/chruby/auto.sh
chruby ruby-3.1.2

然后安装Ruby,如下的代码安装并使用最新的ruby

ruby-install --latest ruby

安装之前看下当前系统的ruby的版本:

ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]

SwitchHosts

在安装过程中,可能会提示raw.githubusercontent.com网站的内容不能访问,此时需要配置host,推荐安装SwitchHosts
host配置如下:

185.199.110.133  raw.githubusercontent.com

或者参考:

  • ineo6/hosts

配置一个远程的,自动更新的host

然后可能需要重启系统才生效。继续执行ruby-install --latest ruby

chruby

参考:

  • postmodern/chruby

使用chruby命令列出可用的ruby
chruby

使用chruby 3.2.2,选择3.2.2的版本
chruby

cocoapods

参考官方文档:

  • WHAT IS COCOAPODS

安装cocoapods

sudo gem install cocoapods

cocoapods镜像

原始源地址为https://github.com/CocoaPods/Specs.git
参考CocoaPods 镜像使用帮助

$ cd ~/.cocoapods/repos 
$ pod repo remove master
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master

最后进入自己的工程,在自己工程的podFile第一行加上:

source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'

ruby镜像

移除现有的Ruby镜像

 gem sources --remove https://rubygems.org/

添加清华的镜像,参考Ruby Gems 镜像使用帮助

# 添加镜像源并移除默认源
gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/
# 列出已有源
gem sources -l
# 应该只有镜像源一个

gem

gem相关,可参考:

  • RubyGems

查看gem版本:

gem -v

遇到的问题

1.pod install时提示HTTP/2 stream 1 was not closed cleanly before end of the underlying stream

error
按网络上的说法解决:

git config --global http.version HTTP/1.1

其他

可参考:

  • m1 silicon macos 安装 cocoapods
  • CocoaPods 常见问题
http://www.lryc.cn/news/122980.html

相关文章:

  • 枚举缓存工具
  • 【BASH】回顾与知识点梳理(二十五)
  • 什么是Node js?什么是React?有什么区别
  • 使用postman做接口测试
  • VMware Workstation 如何启用复制粘贴
  • 免费小程序商城搭建之b2b2c o2o 多商家入驻商城 直播带货商城 电子商务b2b2c o2o 多商家入驻商城 直播带货商城 电子商务 bbc
  • VSCode-Python传参数进行Debug
  • 实践-传统深度学习
  • 爬虫:使用Selenium模拟人工操作及获取网页内容
  • AOP开发
  • Streamlit项目: 轻松搭建部署个人博客网站
  • 手把手教你如何实现内网搭建电影网站并进行公网访问(保姆级教学)
  • Redis_事务操作
  • python质检工具(pylint)安装使用总结
  • “深入探究JVM:解密Java虚拟机的工作原理“
  • 同济子豪兄模板 半天搞定图像分类
  • 接口自动化测试,Fiddler使用抓包辅助实战,一篇彻底打通...
  • 概念解析 | 隐式神经表示:揭开神经网络黑盒的奥秘
  • 深入浅出PHP封装根据商品ID获取淘宝商品详情数据方法
  • 自动切换HTTP爬虫ip助力Python数据采集
  • 20230811导出Redmi Note12Pro 5G手机的录音机APP的录音
  • Python-OpenCV中的图像处理-傅里叶变换
  • 8.10 用redis实现缓存功能和Spring Cache
  • SPI协议个人记录
  • 【深度学习 video detect】Towards High Performance Video Object Detection for Mobiles
  • 时序预测 | MATLAB实现EEMD-LSTM、LSTM集合经验模态分解结合长短期记忆神经网络时间序列预测对比
  • 【软件工程】面向对象方法-RUP
  • Golang 的面向对象
  • STABLE DIFFUSION模型及插件的存放路径
  • Three.js 设置模型材质纹理贴图和修改材质颜色,材质透明度,材质网格