CocoaPods安装记录

1. 替换Ruby源

将默认的 RubyGems 替换为ruby-china源

  • 先检查源
sudo gem sources -l

结果

*** CURRENT SOURCES ***

https://rubygems.org/
  • 移除旧源
sudo gem sources --remove https://rubygems.org/
  • 添加ruby-china源
sudo gem sources -a http://gems.ruby-china.org/
  • 再检查源,结果
*** CURRENT SOURCES ***

http://gems.ruby-china.org/

2. 更新gem

sudo gem update

3. 安装cocoapods

sudo gem install cocoapods
  • 报错

ERROR: While executing gem ... (Gem::DependencyError)
Unable to resolve dependencies: cocoapods requires cocoapods-core (= 1.2.1), cocoapods-downloader (< 2.0, >= 1.1.3), cocoapods-trunk (< 2.0, >= 1.2.0), molinillo (~> 0.5.7), xcodeproj (< 2.0, >= 1.4.4), colored2 (~> 3.1), ruby-macho (~> 1.1)

  • 换个方式更新gem
sudo gem update --system
  • 重新执行安装
sudo gem install cocoapods
  • 又特么报错(无文件操作权限)

ERROR:While executing gem ... (Errno::EPERM)

Operation not permitted - /usr/bin/xcodeproj

  • 终极安装命令
sudo gem install -n /usr/local/bin cocoapods --pre

4. pod setup (慢)

使用国内镜像

pod repo remove master
pod repo add master [https://gitcafe.com/akuandev/Specs.git](https://gitcafe.com/akuandev/Specs.git)
git clone [https://git.coding.net/CocoaPods/Specs.git](https://git.coding.net/CocoaPods/Specs.git) ~/.cocoapods/repos/master

最后pod --versionpod repo update

5. 在项目根目录创建Podfile(每次修改都要pod update)

image.png

记得在platform :ios, '10.3'加上iOS版本号,否则会报错

image.png

现在可以pod updatepod installpod update时就包含了pod install

参考链接:

  • iOS 入门(2):管理第三方库
  • cocoaPods安装2017 以及遇到的坑
  • 执行pod setup很慢很慢解决方案
  • 用CocoaPods做iOS程序的依赖管理

你可能感兴趣的:(CocoaPods安装记录)