CocoasPods的升级及使用

释放双眼,带上耳机,听听看~!

一,CocoasPods的升级

1,打开终端,查看当前cocoapods版本

//输入pod --version  此时我的版本是1.3.1
Last login: Fri May 18 16:31:00 on ttys000
lizhendeMacBook-Pro:~ twinkleo$ pod --version
1.3.1

2,升级之前我们需要了解当前安装的Ruby源地址

//输入gem source -l  目前应该都是https://gems.ruby-china.org/
lizhendeMacBook-Pro:~ twinkleo$ gem source -l
*** CURRENT SOURCES ***

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

3,输入命令,重新安装cocoapods

//输入sudo gem install cocoapods  然后输入电脑密码
lizhendeMacBook-Pro:~ twinkleo$ sudo gem install cocoapods
Password:

4,输入密码后Enter运行,有可能会报异常

lizhendeMacBook-Pro:~ twinkleo$ sudo gem install cocoapods
Password:
Fetching: cocoapods-core-1.5.2.gem (100%)
Successfully installed cocoapods-core-1.5.2
Fetching: cocoapods-downloader-1.2.0.gem (100%)
Successfully installed cocoapods-downloader-1.2.0
Fetching: molinillo-0.6.5.gem (100%)
Successfully installed molinillo-0.6.5
Fetching: nanaimo-0.2.5.gem (100%)
Successfully installed nanaimo-0.2.5
Fetching: xcodeproj-1.5.9.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.

5,解决异常

//输入sudo gem install -n /usr/local/bin cocoapods
lizhendeMacBook-Pro:~ twinkleo$ sudo gem install -n /usr/local/bin cocoapods
Successfully installed xcodeproj-1.5.9
Fetching: cocoapods-1.5.2.gem (100%)
Successfully installed cocoapods-1.5.2
Parsing documentation for xcodeproj-1.5.9
Installing ri documentation for xcodeproj-1.5.9
Parsing documentation for cocoapods-1.5.2
Installing ri documentation for cocoapods-1.5.2
Done installing documentation for xcodeproj, cocoapods after 4 seconds
2 gems installed
lizhendeMacBook-Pro:~ twinkleo$

6,查看版本,升级成功

//此时最新版为1.5.2 升级成功
lizhendeMacBook-Pro:~ twinkleo$ pod --version
1.5.2

二,CocoasPods的使用

1,cd目标项目

lizhendeMacBook-Pro:~ twinkleo$ cd /Users/twinkleo/Desktop/HammerHelper 

2,创建Podfile文件

lizhendeMacBook-Pro:HammerHelper twinkleo$ vim Podfile

3,Podfile文件中的内容

platform:ios, '8.0'
use_frameworks!
inhibit_all_warnings!
target "HammerHelper" do

pod 'AFNetworking','~>3.1.0'
pod 'SDWebImage’
pod 'MBProgressHUD'
pod 'MJExtension'
pod 'IQKeyboardManager'
pod 'NJKWebViewProgress'
pod 'MJRefresh'
pod 'Masonry'
pod 'ReactiveCocoa','~>2.5.0'
pod 'FWSideMenu'

end
"Podfile" 17L, 302C

4,导入第三方

lizhendeMacBook-Pro:HammerHelper twinkleo$ pod install
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (3.1.0)
Installing FMDB (2.7.2)
Installing IQKeyboardManager (6.0.3)
Installing MBProgressHUD (1.1.0)
Installing MJExtension (3.0.13)
Installing MJRefresh (3.1.15.3)
Installing Masonry (1.1.0)
Installing NJKWebViewProgress (0.2.3)
Installing ReactiveCocoa (2.5)
Installing SDWebImage (4.3.3)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `HammerHelper.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There are 10 dependencies from the Podfile and 10 total pods installed.

[!] Smart quotes were detected and ignored in your Podfile. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.
lizhendeMacBook-Pro:HammerHelper twinkleo$

5,完成,关闭项目,重新打开白色XXXXXXX.xcworkspace项目

完整顺序如下:

Last login: Fri May 18 16:31:00 on ttys000
lizhendeMacBook-Pro:~ twinkleo$ pod --version
1.3.1
lizhendeMacBook-Pro:~ twinkleo$ gem source -l
*** CURRENT SOURCES ***

https://gems.ruby-china.org/
lizhendeMacBook-Pro:~ twinkleo$ sudo gem install cocoapods
Password:
Fetching: cocoapods-core-1.5.2.gem (100%)
Successfully installed cocoapods-core-1.5.2
Fetching: cocoapods-downloader-1.2.0.gem (100%)
Successfully installed cocoapods-downloader-1.2.0
Fetching: molinillo-0.6.5.gem (100%)
Successfully installed molinillo-0.6.5
Fetching: nanaimo-0.2.5.gem (100%)
Successfully installed nanaimo-0.2.5
Fetching: xcodeproj-1.5.9.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.
lizhendeMacBook-Pro:~ twinkleo$ sudo gem install -n /usr/local/bin cocoapods
Successfully installed xcodeproj-1.5.9
Fetching: cocoapods-1.5.2.gem (100%)
Successfully installed cocoapods-1.5.2
Parsing documentation for xcodeproj-1.5.9
Installing ri documentation for xcodeproj-1.5.9
Parsing documentation for cocoapods-1.5.2
Installing ri documentation for cocoapods-1.5.2
Done installing documentation for xcodeproj, cocoapods after 4 seconds
2 gems installed
lizhendeMacBook-Pro:~ twinkleo$ pod --version
1.5.2
lizhendeMacBook-Pro:~ twinkleo$ cd /Users/twinkleo/Desktop/HammerHelper 
lizhendeMacBook-Pro:HammerHelper twinkleo$ vim Podfile
lizhendeMacBook-Pro:HammerHelper twinkleo$ pod install
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (3.1.0)
Installing FMDB (2.7.2)
Installing IQKeyboardManager (6.0.3)
Installing MBProgressHUD (1.1.0)
Installing MJExtension (3.0.13)
Installing MJRefresh (3.1.15.3)
Installing Masonry (1.1.0)
Installing NJKWebViewProgress (0.2.3)
Installing ReactiveCocoa (2.5)
Installing SDWebImage (4.3.3)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `HammerHelper.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There are 10 dependencies from the Podfile and 10 total pods installed.

[!] Smart quotes were detected and ignored in your Podfile. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.
lizhendeMacBook-Pro:HammerHelper twinkleo$

人已赞赏
iOS文章

iOS NSString的常用方法

2019-10-11 12:11:25

iOS文章

iOS知识点集锦

2019-10-11 12:28:18

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索