安装CocoPods
打开终端
1.修改/移除安装包的源
gem sources -remove https://rubygems.org/
2.添加安装包的源 输入
gem sources --a https://ruby.taobao.org
出现
*** CURRENT SOURCES *** https://ruby.taobao.org
3.安装Cocoapods 输入
gem install cocoapods
成功出现
Successfully installed cocoapods-0.39.0 Parsing documentation for cocoapods-0.39.0 1 gem installed
————————————————————————————————————————————————————
失败原因1出现
Fetching: cocoapods-0.39.0.gem (100%) ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
获取权限 输入
sudo gem install cocoapods
出现
Password:
输入本机密码
成功出现
Successfully installed cocoapods-0.39.0 Parsing documentation for cocoapods-0.39.0 1 gem installed
其他错误
错误原因2:
RCF 200
解决:
sudo rm .cocoapods
错误原因3:
Xcode path -switch
解决:
Xcode -switch。。。。(修改Xcode目录)
错误原因4:
error status 500 网络错误,无法连接到github
解决:
等待修复网络
错误原因5:
终端内输入
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
错误原因6:
终端内输入
sudo rm -fr ~/.cocoapods/repos/master
安装Cocoapods成功
=================================================================
使用Cocoapod 添加第三方库
终端内输入关键词 查看第三方库版本 以AFNetworking为例
pod search AFNetworking
出现
-> AFNetworking (3.0.4) A delightful iOS and OS X networking framework. pod 'AFNetworking', '~> 3.0.4' - Homepage: https://github.com/AFNetworking/AFNetworking - Source: https://github.com/AFNetworking/AFNetworking.git - Versions: 3.0.4, 3.0.3, 3.0.2, 3.0.1, 3.0.0, 3.0.0-beta.3, 3.0.0-beta.2, 3.0.0-beta.1, 2.6.3, 2.6.2, 2.6.1, 2.6.0, 2.5.4, 2.5.3, 2.5.2, 2.5.1, 2.5.0, 2.4.1, 2.4.0, 2.3.1, 2.3.0, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.1.0, 2.0.3, 2.0.2, 2.0.1, 2.0.0, 2.0.0-RC3, 2.0.0-RC2, 2.0.0-RC1, 1.3.4, 1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.2.1, 1.2.0, 1.1.0, 1.0.1, 1.0, 1.0RC3, 1.0RC2, 1.0RC1, 0.10.1, 0.10.0, 0.9.2, 0.9.1, 0.9.0, 0.7.0, 0.5.1 [master repo] - Subspecs: - AFNetworking/Serialization (3.0.4) - AFNetworking/Security (3.0.4) - AFNetworking/Reachability (3.0.4) - AFNetworking/NSURLSession (3.0.4) - AFNetworking/UIKit (3.0.4) //略……
1打开终端cd到工程目录
2 创建一个文本文件
vim Podfile
编辑podfile页面
platform :iOS, '8.0' //平台系统版本 pod ‘AFNetWorking’,'2.5.0'// 添加afnetworking 2.5.0版本
3.按 Esc(退出) —— : (冒号)—— wq 保存退出
4.安装第三方库 退出编辑之后在终端输入安装
pod install --verbose-no-repo-update
跳过检查更新阶段
--verbose-n-repo-update
5.更新pod 第三方库
pod update --verbose-no-repo-update