iOS开发用CocoaPods做iOS程序的依赖管理
安装方式异常简单 , Mac 下都自带 ruby,使用 ruby 的 gem 命令即可下载安装:
$ sudo gem install cocoapods $ pod setup
如果你的 gem 太老,可能也会有问题,可以尝试用如下命令升级 gem:
sudo gem update --system
另外,ruby 的软件源 https://rubygems.org 因为使用的是亚马逊的云服务,所以被墙了,需要更新一下 ruby 的源,使用如下代码将官方的 ruby 源替换成国内淘宝的源:
gem sources --remove https://rubygems.org/ gem sources -a https://ruby.taobao.org/ gem sources -l
还有一点需要注意,pod setup在执行时,会输出Setting up CocoaPods master repo,但是会等待比较久的时间。这步其实是 Cocoapods 在将它的信息下载到 ~/.cocoapods目录下,如果你等太久,可以试着 cd 到那个目录,用du -sh *来查看下载进度。你也可以参考本文接下来的使用 cocoapods 的镜像索引一节的内容来提高下载速度。
//////新建工程 CocoaPods
suchao:Desktop dllo$ cd CocoaPods
suchao:CocoaPods dllo$ ls
suchao:CocoaPods dllo$ pod init //创建podfile文件
suchao:CocoaPods dllo$ pod install
编辑文件
platform :ios
pod 'RegexKitLite-NoWarning', '~> 1.1.0'
platform :ios, '7.0'
pod "AFNetworking", "~> 2.0”
suchao:CocoaPods dllo$ pod install
//////////////////////////
生敲也可以 设置这个了 就可以直接索引出了
cocoapods 无法引入头文件的问题
选择工程的 Target -> Build Settings 菜单,找到\”User Header Search Paths\”设置项
新增一个值"$(PODS_ROOT)",并且选择\”recursive\”,这样xcode就会在项目目录中递归搜索文件
屏幕快照 2015-10-29 上午11.57.48.png
使用 CocoaPods 的镜像索引
所有的项目的 Podspec 文件都托管在https://github.com/CocoaPods/Specs。第一次执行pod setup时,CocoaPods 会将这些podspec索引文件更新到本地的 ~/.cocoapods/目录下,这个索引文件比较大,有 80M 左右。所以第一次更新时非常慢,笔者就更新了将近 1 个小时才完成。
一个叫 akinliu 的朋友在 gitcafe 和 oschina 上建立了 CocoaPods 索引库的镜像,因为 gitcafe 和 oschina 都是国内的服务器,所以在执行索引更新操作时,会快很多。如下操作可以将 CocoaPods 设置成使用 gitcafe 镜像:
pod repo remove master pod repo add master https://gitcafe.com/akuandev/Specs.git pod repo update
将以上代码中的 https://gitcafe.com/akuandev/Specs.git 替换成 http://git.oschina.net/akuandev/Specs.git 即可使用 oschina 上的镜像。
、、、、、、、、、、、、
Last login: Thu Oct 29 11:09:47 on ttys003
suchao:~ dllo$ sudo gem install cocoapods
Password:
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from http://ruby.taobao.org/ - bad response Not Found 404 (http://ruby.taobao.org/latest_specs.4.8.gz)
suchao:~ dllo$ gem sougem sources --remove https://ruby.taobao.org
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command sougem
suchao:~ dllo$ gem sources --remove https://ruby.taobao.org/
source https://ruby.taobao.org/ not present in cache
suchao:~ dllo$ gem sources -l
*** CURRENT SOURCES ***
http://ruby.taobao.org/
suchao:~ dllo$ gem sources --remove https://rubygems.org/
source https://rubygems.org/ not present in cache
suchao:~ dllo$ gem sources -a https://ruby.taobao.org/
https://ruby.taobao.org/ added to sources
suchao:~ dllo$ sudo gem install cocoapods
Password:
Fetching: nap-1.0.0.gem (100%)
Successfully installed nap-1.0.0
Fetching: cocoapods-core-0.39.0.gem (100%)
Successfully installed cocoapods-core-0.39.0
Fetching: claide-0.9.1.gem (100%)
Successfully installed claide-0.9.1
Fetching: xcodeproj-0.28.2.gem (100%)
Successfully installed xcodeproj-0.28.2
Fetching: cocoapods-downloader-0.9.3.gem (100%)
Successfully installed cocoapods-downloader-0.9.3
Fetching: cocoapods-search-0.1.0.gem (100%)
Successfully installed cocoapods-search-0.1.0
Fetching: cocoapods-stats-0.6.2.gem (100%)
Successfully installed cocoapods-stats-0.6.2
Fetching: cocoapods-try-0.5.1.gem (100%)
Successfully installed cocoapods-try-0.5.1
Fetching: cocoapods-trunk-0.6.4.gem (100%)
Successfully installed cocoapods-trunk-0.6.4
Fetching: molinillo-0.4.0.gem (100%)
Successfully installed molinillo-0.4.0
Fetching: cocoapods-0.39.0.gem (100%)
Successfully installed cocoapods-0.39.0
Parsing documentation for nap-1.0.0
Installing ri documentation for nap-1.0.0
Parsing documentation for cocoapods-core-0.39.0
Installing ri documentation for cocoapods-core-0.39.0
Parsing documentation for claide-0.9.1
Installing ri documentation for claide-0.9.1
Parsing documentation for xcodeproj-0.28.2
Installing ri documentation for xcodeproj-0.28.2
Parsing documentation for cocoapods-downloader-0.9.3
Installing ri documentation for cocoapods-downloader-0.9.3
Parsing documentation for cocoapods-search-0.1.0
Installing ri documentation for cocoapods-search-0.1.0
Parsing documentation for cocoapods-stats-0.6.2
Installing ri documentation for cocoapods-stats-0.6.2
Parsing documentation for cocoapods-try-0.5.1
Installing ri documentation for cocoapods-try-0.5.1
Parsing documentation for cocoapods-trunk-0.6.4
Installing ri documentation for cocoapods-trunk-0.6.4
Parsing documentation for molinillo-0.4.0
Installing ri documentation for molinillo-0.4.0
Parsing documentation for cocoapods-0.39.0
Installing ri documentation for cocoapods-0.39.0
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/latest_specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/latest_specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
11 gems installed
suchao:~ dllo$
suchao:~ dllo$ pod setup
Setting up CocoaPods master repo
Setup completed
suchao:~ dllo$ cd D
Desktop/ Documents/ Downloads/
suchao:~ dllo$ cd Desktop/
suchao:Desktop dllo$ ls
0710DistributionCer.p12
AdobeFlashPlayer_19_a_install-2.dmg
CarProfile.mobileprovision
CertificateName.p12
CertificateName.pem
CertificateSigningRequest.certSigningRequest
CocoaPods
Night
PUSHOrcal123.mobileprovision
aps_development.cer
dash
iconfont-xiala.png
ios开班用误删
logo
tabBar图标
tupbiao
夜间
桌面
高亮
点击Section下拉Cell
点击Section下拉cell 2
启动页
引导页
摇一摇 2
引导页(完整版)
引导页(最终版)
启动页Car
全屏浏览
可可旅行
课程代码
课程课件
爱车达人 2
屏幕快照 2015-10-28 下午8.37.27.png
屏幕快照 2015-10-28 下午8.37.36.png
屏幕快照 2015-10-29 上午9.06.05.png
爱车达人.zip
未命名文件夹
爱车资讯截图
未命名文件夹 2
suchao:Desktop dllo$ cd CocoaPods
suchao:CocoaPods dllo$ ls
CocoaPods CocoaPodsTests
CocoaPods.xcodeproj CocoaPodsUITests
suchao:CocoaPods dllo$ vim podfile
suchao:CocoaPods dllo$ pod install
[!] Invalid `Podfile` file: undefined method `tform' for #<Pod::Podfile:0x007fddebb1a4d8>. Updating CocoaPods might fix the issue.
# from /Users/dllo/Desktop/CocoaPods/Podfile:1
# -------------------------------------------
> tform :ios
# pod 'RegexKitLite-NoWarning', '~> 1.1.0'
# -------------------------------------------
suchao:CocoaPods dllo$ vim podfile
suchao:CocoaPods dllo$ pod install
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (2.6.1)
Installing RegexKitLite-NoWarning (1.1.0)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `CocoaPods.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There are 2 dependencies from the Podfile and 2 total
pods installed.
suchao:CocoaPods dllo$