安装CocoaPods
>>方法一 (最简洁)
新建一个项目:项目名自定
>>方法二
->>下载CocoaPods地址<<- [方便快捷 直接在CocoaPods运行demo ]
打开Xcode 运行demo 然后运行 下载好的 CocoaPods.app ->> 如下:
>>方法三
1.打开终端输入ruby -v(确实安装了,如果这个版本接下来工作失败了,就更新下ruby)b更新ruby )
示例:
ritekiMac-mini:PodTest lucky$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
ritekiMac-mini:PodTest lucky$
2.终端输入如下命令(把Ruby镜像指向taobao,避免被墙,你懂得)
gem sources --remove https://rubygems.org/
gem sources -a https://ruby.taobao.org/
gem sources -l(用来检查使用替换镜像位置成功)
示例:
ritekiMac-mini:~ lucky$ gem sources --removehttps://rubygems.org/
https://rubygems.org/ removed from sources
ritekiMac-mini:~ lucky$ gem sources -ahttps://ruby.taobao.org/
https://ruby.taobao.org/ added to sources
ritekiMac-mini:~ lucky$ gem sources -l
*** CURRENTSOURCES***
3.下载安装CocoaPods
终端输入:sudo gem install cocoa pods
这个地方很坑,之前安装cocoapods一直是没有这个问题的,这里提示Ruby版本要大于或等于2.2.2
于是查看ruby版本
$ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
果然这里就要升级Ruby版本啦
查看目前的所有ruby版本:
$rvm list known
如果提示command not found 请先安装rvm
$curl -L get.rvm.io | bash -s stable
如果出现错误:可按照下面的链接进行一步步操作:
CocoaPods 安装详解 - http://blog.csdn.net/u012960049/article/details/52275272
示例:
1.ritekiMac-mini:~ lucky$ sudo gem install cocoapods
2.Successfully installed cocoapods-1.0.1
3.Parsing documentation for cocoapods-1.0.1
4.1 gem installed
4.使用CocoaPods
a新建一个项目,名字PodTest
b终端中,cd到项目总目录(注意:包含PodTest文件夹、PodTest.xcodeproj、PodTestTest的那个总目录)
示例:
cd /Users/lucky/Desktop/PodTest
5.建立Podfile(配置文件)
接着下一步,终端输入vim Podfile
示例:
platform :ios, '9.0'
target 'PodTest' do
pod 'MBProgressHUD', '~> 0.9.2'
end
6.确定终端cd到项目总目录,然后输入pod install,等待一会,大约3分钟。
示例:
bogon:PodTest xuweibin$ pod install
Analyzing dependencies
Downloading dependencies
Installing MBProgressHUD (0.9.2)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `PodTest.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total
pod installed.
终端输入
*******************************************************************************
platform :ios, '9.0'
target 'E-IThome' do// E-IThome文件名
pod 'EaseMobSDK', :git => 'https://github.com/easemob/sdk-ios-cocoapods.git'
pod 'JSONModel'
pod "AFNetworking", "~> 3.0"
pod 'BmobSDK'
pod 'YYText'
pod 'MBProgressHUD', '~> 0.9.2'
pod 'BaiduMapKit' #百度地图SDK
end
*******************************************************************************