2014年1月16日星期四

iOS笔记:CocoaPods

吐槽一下:类似Maven、Gradle,当然更像gradle, 很怀疑maven是学院派的人主导的产品(一堆xml让谁看啊?!),gradle才有搞工程人的实际品质。

安装CocoaPods需要有:
1)Ruby 环境。下面的命令更新Ruby环境。
sudo gem update --system
2) Command Line Tools for Xcode

安装CocoaPod:
sudo gem install cocoapods
pod setup
执行sudo gem install cocoapods时会提示:
rake's executable "rake" conflicts with /usr/bin/rake
Overwrite the executable? [yN]  y
Successfully installed rake-10.1.1
选择y覆盖,否则需要设置user的环境变量。Ref: http://guides.cocoapods.org/using/getting-started.html

创建Podfile:
open -e Podfile
platform :iOS
pod ‘AFNetWorking’, ‘0.9'


运行pod install, 抓取Podfile里指定的库到本地。
pod install

用xcode打开pod install生成的workspace文件,而不是原来的project文件。否则会有下面的错误:ld: library not found for -lPods


RubyGems 是什么? 
The RubyGems software allows you to easily download, install, and use ruby software packages on your system. The software package is called a "gem" and contains a package Ruby application or library.

Gems can be used to extend or modify functionality in Ruby applications. Commonly they're used to distribute reusable functionality that is shared with other Rubyists for use in their applications and libraries. Some gems provide command line utilities to help automate tasks and speed up your work.