crm开发定制CocoaPods安装以及一些问题处理-2022.6.21

CocoaPods简介

CocoaPodscrm开发定制是一个用写的,负责管理ioscrm开发定制项目中第三方开源库的工具,CocoaPodscrm开发定制能让我们集中的,crm开发定制统一的管理第三方开源库,crm开发定制为我们节省设置和更新crm开发定制第三方开源库的时间。

CocoaPods安装

方法一比较简单,如果不行,再尝试方法二。

方法一:使用直接安装

1. 安装Homebrew,如果已安装则忽略

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

2. 安装Cocoapods

brew install cocoapods
  • 1

3. 用安装本地Pods资源库

  • 如果可以科学上网,则从官方资源库下载
git clone https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/trunk
  • 1
  • 如果不行,则从国内的镜像地址下载,速度较快
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git  ~/.cocoapods/repos/trunk
  • 1

方法二:

1. 查看当前ruby版本

ruby -v
  • 1

结果如下,也可能是其他版本,都没事

ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]
  • 1

2. 安装rvm

  • 首先检查是否安装
rvm -v
  • 1

如果显示如下,则表示已经安装,直接进行后续

rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
  • 1
  • 否则,安装rvm,安装完成之后通过上面的步骤检查是否安装成功。
curl -L get.rvm.io | bash -s stable source ~/.bashrcsource ~/.bash_profile
  • 1
  • 2
  • 3
  • 4
  • 5

4. 列出ruby可安装的版本信息

rvm list known
  • 1

显示如下:

# MRI Rubies[ruby-]1.8.6[-p420][ruby-]1.8.7[-head] # security released on head[ruby-]1.9.1[-p431][ruby-]1.9.2[-p330][ruby-]1.9.3[-p551][ruby-]2.0.0[-p648][ruby-]2.1[.10][ruby-]2.2[.10][ruby-]2.3[.8][ruby-]2.4[.10][ruby-]2.5[.8][ruby-]2.6[.6][ruby-]2.7[.2][ruby-]3[.0.0]ruby-head.....
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

5. 安装Homebrew,如果已安装则跳过

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

如果遇到:
Failed to connect to raw.githubusercontent.com port 443: Connection refused
解决方式:
这是由于该网址的域名解析被污染的缘故。通过修改hosts可以解决这个问题:
打开/etc/hosts 文件,添加语句:

    199.232.4.133 raw.githubusercontent.com
  • 1

6. 更换源

要先更换源再安装新的ruby,否则可能会因为装了多个ruby而产生openssl is not available的报错。
如果已经有了多个版本的ruby,参考处理方式:,然后再进行后面的步骤即可。

  • 删除自带的源
gem sources --remove https://rubygems.org/
  • 1
  • 添加新的源
gem sources --add https://gems.ruby-china.com/
  • 1
  • 验证ruby镜像是且仅是ruby-china
gem sources -l
  • 1

7. 安装ruby,建议选择最新版本

rvm install 3.0.0
  • 1

注意:中间会有多次需要操作的地方,根据提示来即可。

设为默认

rvm use 3.0.0 --default
  • 1

8. 安装CocoaPods,以下二选一即可

第一种

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

第二种:如果上述尝试不成功,则直接使用homebrew来安装

brew install cocoapods
  • 1

9. 如果安装了多个Xcode使用下面的命令选择(一般需要选择最近的xcode版本)

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
  • 1

10. 安装本地库

这一步是安装本地库,不安装也没事,项目照常可以pod install,只是不能使用pod search命令。

  • 如果开启了科学上网,建议直接从官方下载安装
git clone https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/trunk
  • 1
  • 也可以通过国内的镜像地址进行安装
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git  ~/.cocoapods/repos/trunk
  • 1

11. 检验成果

pod search Alamofire /// 第一次比较慢,耐心等待按Q退出搜索
  • 1
  • 2

搜索结果:

-> Alamofire (5.6.1)   Elegant HTTP Networking in Swift   pod 'Alamofire', '~> 5.6.1'   - Homepage: https://github.com/Alamofire/Alamofire   - Source:   https://github.com/Alamofire/Alamofire.git   - Versions: 5.6.1, 5.6.0, 5.5.0, 5.4.4, 5.4.3, 5.4.2, 5.4.1, 5.4.0, 5.3.0,   5.2.2, 5.2.1, 5.2.0, 5.1.0, 5.0.5, 5.0.4, 5.0.3, 5.0.2, 5.0.1, 5.0.0,   5.0.0-rc.3, 5.0.0-rc.2, 5.0.0-rc.1, 5.0.0-beta.7, 5.0.0-beta.6, 5.0.0-beta.5,   5.0.0-beta.4, 5.0.0-beta.3, 5.0.0-beta.2, 5.0.0.beta.1, 4.9.1, 4.9.0, 4.8.2,   4.8.1, 4.8.0, 4.7.3, 4.7.2, 4.7.1, 4.7.0, 4.6.0, 4.5.1, 4.5.0, 4.4.0, 4.3.0,   4.2.0, 4.1.0, 4.0.1, 4.0.0, 3.5.1, 3.5.0, 3.4.2, 3.4.1, 3.4.0, 3.3.1, 3.3.0,   3.2.1, 3.2.0, 3.1.5, 3.1.4, 3.1.3, 3.1.2, 3.1.1, 3.1.0, 3.0.1, 3.0.0,   3.0.0-beta.3, 3.0.0-beta.2, 3.0.0-beta.1, 2.0.2, 2.0.1, 2.0.0, 2.0.0-beta.4,   2.0.0-beta.3, 2.0.0-beta.2, 2.0.0-beta.1, 1.3.1, 1.3.0, 1.2.3, 1.2.2, 1.2.1,   1.2.0, 1.1.5, 1.1.4, 1.1.3 [trunk repo]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

大功告成!!!

补充:Cocoapods使用中的一些问题

Cocoapods无法获取到最新的版本

解决办法:

  1. 最简单的办法,就是删除search的索引
rm ~/Library/Caches/CocoaPods/search_index.jsonpod search DFAXUIElement
  • 1
  • 2
  1. 因为本地库的缓存没有进行更新。删除本地缓存,重新setup。强烈建议该方法。方法如下:
pod repo remove mastercd ~/.cocoapods/reposgit clone --depth 1 https://github.com/CocoaPods/Specs.git masterrm ~/Library/Caches/CocoaPods/search_index.json
  • 1
  • 2
  • 3
  • 4
  1. 直接更新仓库
pod install --repo-update
  • 1

Unable to find a pod with name, author, summary, or description matching

  1. 重新进行pod的setup,在终端输入以下命令:
pod setup
  • 1

如果出现setup completed,说明执行pod setup成功。这时候就可以继续执行pod search 如果还出现报错,如下:

Unable to find a pod with name, author, summary, or descriptionmatching
  • 1

执行如下命令即可:

rm ~/Library/Caches/CocoaPods/search_index.jsonpod search
  • 1
  • 2

如果还不行,就删除本地仓库,重新setup

od repo remove mastercd ~/.cocoapods/reposgit clone https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/trunkrm ~/Library/Caches/CocoaPods/search_index.json
  • 1
  • 2
  • 3
  • 4

卸载Cocoapods

sudo gem uninstall cocoapods
  • 1

Unable to find a pod with name, author, summary, or description matching xxx

pod setuprm -rf ~/Library/Caches/Cocoapods
  • 1
  • 2
网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发