CocoaPods的安装(以下命令均在终端下操作)
来源:互联网 发布:王力宏 乐器 知乎 编辑:程序博客网 时间:2024/05/17 04:05
m
1.安装方式简单,Mac下都自带ruby,使用ruby的gem命令即可下载安装:
sudo gem install cocoapodspod setup
2.如果你的gem太老,可能也会有问题,可以尝试用如下命令升级gem:
sudo gem update --system
3.另外,ruby的软件源http://rubygems.org因为使用的是亚马逊的云服务,所以被墙了,需要更新一下ruby的源,使用如下代码将官方的ruby源替换成国内淘宝的源:
gem sources --remove http://rubygems.org/gem sources -a https://ruby.taobao.org/gem sources -l
4.(验证)输入下面命令后,
gem sources -l
如果出现下面
*** CURRENT SOURCES ***https://ruby.taobao.org/
5.此时就可以进行安装,
sudo gem install cocoapods
出现以下
Successfully installed cocoapods-0.39.0Parsing documentation for cocoapods-0.39.01 gem installed
CocoaPods的使用介绍
1.使用时需要(在想要加入第三方的工程下)新建一个名为Podfile的文件(先将工程路径拖进终端,使在此文件中创建)
cd /Users/lanou3g/Desktop/未命名文件夹/textjinzhao:text lanou3g$ touch Podfile
2.然后将依赖的库(第三方)名字依次列在文件中
jinzhao:text lanou3g$ vim Podfile//编写方式,如以下pod 'SDWebImage', '~>3.7'
终端进入
vim Podfile(如果存在直接打开,不存在创建后打开)
此时进入文件,如果是编辑模式,即可以进行编辑,或者是命令模式
编辑模式—>ESC+shift+冒号键+w键,此时可以写入
编辑模式—>ESC+shift+冒号键+q键,此时已经离开
编辑模式—>ESC+shift+冒号键+wq键,此时写入并离开
编辑模式—>ESC+shift+冒号键+wq!键,强制写入并离开
命令模式—>i键—>进入编辑模式
set nu:显示行号
ESC后 输入dd 可以删掉一行
3.然后编辑好的Podfile文件放到根目录中,执行如下命令即可:
cd "you project home"//此为将文件放到根目录,小编本就在根目录下创建,故此步骤可省略pod install//圆荚体安装
4.得到,例如出现以下,即为加载完毕
Updating local specs repositoriesAnalyzing dependenciesDownloading dependenciesInstalling SDWebImage (3.7.3)Generating Pods projectIntegrating client project[!] Please close any current Xcode sessions and use `text.xcworkspace` for this project from now on.Sending statsPod installation complete! There is 1 dependency from the Podfile and 1 totalpod installed.
5.你如果不知道cocoaPods管理的库中,是否有你想要的库,那么你可以同过pod search命令进行查找,以下是我用pod 'SDWebImage', '~>3.7'查找到的所有可用的库:
-> ComponentKit+SDWebImage (0.0.2) [DEPRECATED] CKNetworkImageDownloading implementation for SDWebImage. pod 'ComponentKit+SDWebImage', '~> 0.0.2' - Homepage: https://github.com/eyeem/ComponentKit-SDWebImage - Source: https://github.com/eyeem/ComponentKit-SDWebImage.git - Versions: 0.0.2, 0.0.1 [master repo]-> DSActivityIndicatorSDWebImage (1.0.6) The easiest way to add a UIActivityView to your SDWebImage view. pod 'DSActivityIndicatorSDWebImage', '~> 1.0.6' - Homepage: https://github.com/diejmon/UIActivityIndicator-for-SDWebImage - Source: https://github.com/diejmon/UIActivityIndicator-for-SDWebImage.git - Versions: 1.0.6, 1.0 [master repo]-> IMY_SDWebImage_Wrapper (1.0) SDWebImageView 进度条支持 pod 'IMY_SDWebImage_Wrapper', '~> 1.0' - Homepage: https://github.com/meiyoudev/IMY_SDWebImage_Wrapper - Source: https://github.com/meiyoudev/IMY_SDWebImage_Wrapper.git - Versions: 1.0 [master repo]-> SDWebImage (3.7.3) Asynchronous image downloader with cache support with an UIImageView category. pod 'SDWebImage', '~> 3.7.3' - Homepage: https://github.com/rs/SDWebImage - Source: https://github.com/rs/SDWebImage.git - Versions: 3.7.3, 3.7.2, 3.7.1, 3.7.0, 3.6, 3.5.4, 3.5.2, 3.5.1, 3.5, 3.4, 3.3, 3.2, 3.1, 3.0, 2.7.4, 2.7, 2.6, 2.5, 2.4 [master repo] - Subspecs: - SDWebImage/Core (3.7.3) - SDWebImage/MapKit (3.7.3) - SDWebImage/WebP (3.7.3)-> SDWebImage+ExtensionSupport (3.7.1.2) Asynchronous image downloader with cache support with an UIImageView category. Added SD_APP_EXTENSION macro for ios8 extensions pod 'SDWebImage+ExtensionSupport', '~> 3.7.1.2' - Homepage: https://github.com/rs/SDWebImage - Source: https://github.com/glassoff/SDWebImage.git - Versions: 3.7.1.2, 3.7.1.1 [master repo] - Subspecs: - SDWebImage+ExtensionSupport/Core (3.7.1.2) - SDWebImage+ExtensionSupport/MapKit (3.7.1.2)-> SDWebImage-Category (1.4) 方便快捷的为UIImageView加上下载进度条,支持:下载失败显示裂图,显示 点击下载图片 pod 'SDWebImage-Category', '~> 1.4' - Homepage: https://github.com/li6185377/SDWebImage-Category - Source: https://github.com/li6185377/SDWebImage-Category.git - Versions: 1.4, 1.3, 1.2, 1.1.1, 1.1 [master repo]-> SDWebImage-ProgressView (0.4.0) Category on UIImageView, adding a progress view while images are downloaded using SDWebImage. pod 'SDWebImage-ProgressView', '~> 0.4.0' - Homepage: https://github.com/kevinrenskers/SDWebImage-ProgressView - Source: https://github.com/kevinrenskers/SDWebImage-ProgressView.git - Versions: 0.4.0, 0.3.1, 0.3.0, 0.2.0, 0.1.0 [master repo]-> SDWebImageFix (3.7.3.2) Asynchronous image downloader with cache support with an UIImageView category. pod 'SDWebImageFix', '~> 3.7.3.2' - Homepage: https://github.com/jumperb/SDWebImage - Source: https://github.com/jumperb/SDWebImage.git - Versions: 3.7.3.2, 3.7.3.1 [master repo] - Subspecs: - SDWebImageFix/Core (3.7.3.2) - SDWebImageFix/MapKit (3.7.3.2) - SDWebImageFix/WebP (3.7.3.2)-> UIActivityIndicator-for-SDWebImage (1.2) The easiest way to add a UIActivityView to your SDWebImage view. pod 'UIActivityIndicator-for-SDWebImage', '~> 1.2' - Homepage: https://github.com/JJSaccolo/UIActivityIndicator-for-SDWebImage - Source: https://github.com/JJSaccolo/UIActivityIndicator-for-SDWebImage.git - Versions: 1.2, 1.1, 1.0.5, 1.0.4, 1.0.3, 1.0.2, 1.0.0 [master repo]-> UIActivityIndicator-for-SDWebImage+UIButton (1.2) The easiest way to add a UIActivityView to your SDWebImage view. pod 'UIActivityIndicator-for-SDWebImage+UIButton', '~> 1.2' - Homepage: https://github.com/nobre84/UIActivityIndicator-for-SDWebImage - Source: https://github.com/nobre84/UIActivityIndicator-for-SDWebImage.git - Versions: 1.2 [master repo]-> UIImageView+SDWebImage_M13ProgressSuite (0.1.1) Category of UIImageView, downloaded with SDWebImage, progressed with M13ProgressSuite. pod 'UIImageView+SDWebImage_M13ProgressSuite', '~> 0.1.1' - Homepage: https://github.com/Jowyer/UIImageView-SDWebImage_M13ProgressSuite - Source: https://github.com/Jowyer/UIImageView-SDWebImage_M13ProgressSuite.git - Versions: 0.1.1, 0.1.0 [master repo]
6.现在,你的所有第三方库都已经下载完成并且设置好了编译参数和依赖,你只需记住如下2点即可:
1.使用CocoPods生成的.xcworkspace文件来打开工程,而不是以前的.xcodeproj文件.
2.每次更改了Podfile文件,你需要重新执行一次pod update命令.
0 0
- CocoaPods的安装(以下命令均在终端下操作)
- 安装cocoapods的终端命令
- 在Linux下操作MySQL的简单命令
- 在.NET Framework 2.0即以下平台下操作UDT
- iOS安装CocoaPods的终端命令
- Linux - Linux下操作Tomcat的命令
- cocoaPods安装使用终端命令
- 在命令提示符下操作Sql Server 2005服务
- 在telnet下操作memcache详解(操作命令详解)
- Python下操作excel文件--在win7下入xlrd库的安装和引入
- CocoaPods 的安装步骤及常用终端命令
- linux下操作mysql命令
- linux下操作tomcat命令
- LInux下操作命令之一
- linux下操作命令收集
- 几个简单的linux下操作的命令
- linux命令行下操作mysql的命令汇总
- aix下操作oracle的部分命令,用到啥就记点
- Objective-C 单例模式
- Android中Intent传递对象的两种方法(Serializable,Parcelable)
- Ubuntu 下搭建django开发环境
- iOS开发学习之导航控制器和应用程序的生命周期
- ADO访问Excel 2007
- CocoaPods的安装(以下命令均在终端下操作)
- 蓝桥杯 地宫取宝
- BZOJ1044/HAOI2008木棍分割
- 跌跌撞撞两年,告一段落,开始写博客
- php技术论坛开通了
- setRequestedOrientation 改变屏幕方法
- 利用Cydia Substrate进行Android JAVA HOOK
- 基于ARM的音视频采集与传输系统
- 用python自动下载妹子图