美文网首页
CocoaPods安装及使用

CocoaPods安装及使用

作者: 我非起点亦非终点 | 来源:发表于2016-08-29 15:22 被阅读0次

1.更新ruby

gem sources --removehttps://rubygems.org/

gem sources -ahttps://ruby.taobao.org/

gem sources -l

2.安装CocoaPods

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

3.对项目进行配置

1.新建一个项目PodTest

2.cd 到项目根目录

3.输入 vim Podfile 键盘点击i,进入编辑模式,输入

platform :ios, ‘8.0'

pod 'MBProgressHUD', '~> 0.9.1'

按Esc,输入:进入vim命令模式,然后冒号后面输入wq

这时项目根目录会多出一个Podfile文件

4.pod install --verbose --no-repo-update

这时,项目文件夹会变成这样,这时安装成功

5.需要更多第三方库,比如Alamofire

可以 pod search Alamofire,选择需要的版本

cd到项目根目录,vim Podfile进入编辑模式

target "PodTest" do

platform :ios, '8.0'

use_frameworks!  

pod 'MBProgressHUD', '~> 0.9.1'

pod'Alamofire','~>2.0'

end

然后执行pod install --verbose --no-repo-update

OK,安装成功了

PS:安装完成后,如果在#import导入头文件时,不会自动提示

选择taget,点击BuildSetting,搜索Search Paths,双击User Header Search Paths,输入$(PODS_ROOT),选择recursive,这时就会自动提示了

相关文章

网友评论

      本文标题:CocoaPods安装及使用

      本文链接:https://www.haomeiwen.com/subject/newxettx.html