CocoaPod 使用方法
huangyichengdeMacBook-Pro:~ Jack$ pod search AFNetworking
/Library/Ruby/Site/2.0.0/rubygems.rb:250:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
from /Library/Ruby/Site/2.0.0/rubygems.rb:278:in `activate_bin_path'
from /usr/local/bin/pod:22:in `<main>'
huangyichengdeMacBook-Pro:~ Jack$ which pod
/usr/local/bin/pod
huangyichengdeMacBook-Pro:~ Jack$ sudo rm -rf /usr/local/bin/pod
Password:
huangyichengdeMacBook-Pro:~ Jack$ gem list
*** LOCAL GEMS ***
activesupport (4.2.6)
bigdecimal (1.2.7, default: 1.2.0)
CFPropertyList (2.3.3, 2.2.8)
claide (1.0.1, 1.0.0)
cocoa (0.1.6)
cocoapods (1.1.1)
cocoapods-core (1.1.1, 1.0.1)
cocoapods-deintegrate (1.0.1, 1.0.0)
cocoapods-downloader (1.1.2, 1.1.1, 1.0.1)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.1.1, 1.0.0)
cocoapods-try (1.1.0, 1.0.0)
colored (1.2)
concurrent-ruby (1.0.2)
escape (0.0.4)
ffi (1.9.14)
fourflusher (2.0.1, 2.0.0, 0.3.2)
fuzzy_match (2.0.4)
gh_inspector (1.0.2)
i18n (0.7.0)
io-console (default: 0.4.2)
json (default: 1.7.7)
libxml-ruby (2.6.0)
minitest (5.9.0, default: 4.3.2)
molinillo (0.5.1, 0.4.5)
nap (1.1.0)
netrc (0.7.8)
nokogiri (1.5.6)
pods (0.0.1)
psych (default: 2.0.0)
rake (default: 0.9.6)
rdoc (default: 4.0.0)
rubygems-update (2.6.6)
sqlite3 (1.3.7)
test-unit (default: 2.0.0.0)
thread_safe (0.3.5)
tzinfo (1.2.2)
xcodeproj (1.3.3, 1.1.0)
huangyichengdeMacBook-Pro:~ Jack$ sudo gem uninstall cocoapods -v 1.1.1
huangyichengdeMacBook-Pro:~ Jack$ sudo gem uninstall cocoapods-core -v 1.1.1
Successfully uninstalled cocoapods-core-0.39.0
huangyichengdeMacBook-Pro:~ Jack$ sudo gem uninstall cocoapods -v 1.1.1
huangyichengdeMacBook-Pro:~ Jack$ sudo gem install cocoapods
Fetching: cocoapods-core-0.39.0.gem (100%)
Successfully installed cocoapods-core-0.39.0
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/pod
huangyichengdeMacBook-Pro:~ Jack$ sudo gem install -n /usr/local/bin cocoapods
Successfully installed cocoapods-0.39.0
Parsing documentation for cocoapods-0.39.0
Installing ri documentation for cocoapods-0.39.0
1 gem installed
huangyichengdeMacBook-Pro:~ Jack$ gem sources -l
*** CURRENT SOURCES ***
https://ruby.taobao.org/
huangyichengdeMacBook-Pro:~ Jack$ pod setup
Setting up CocoaPods master repo
$ /usr/bin/git -C /Users/heshangyungou/.cocoapods/repos/master pull --ff-only
From https://github.com/CocoaPods/Specs
b9d0b0e..b0077b8 master -> origin/master
Updating b9d0b0e..b0077b8
Fast-forward
Specs/CIColorRGBA/2.3/CIColorRGBA.podspec.json | 25 +++++++++++++++++++++++++
Specs/KSToolkit/0.3.4/KSToolkit.podspec.json | 23 +++++++++++++++++++++++
Specs/KudoCCKit/0.0.4/KudoCCKit.podspec.json | 25 +++++++++++++++++++++++++
Specs/TCTools/0.1.14/TCTools.podspec.json | 19 +++++++++++++++++++
4 files changed, 92 insertions(+)
create mode 100644 Specs/CIColorRGBA/2.3/CIColorRGBA.podspec.json
create mode 100644 Specs/KSToolkit/0.3.4/KSToolkit.podspec.json
create mode 100644 Specs/KudoCCKit/0.0.4/KudoCCKit.podspec.json
create mode 100644 Specs/TCTools/0.1.14/TCTools.podspec.json
Setup completed
huangyichengdeMacBook-Pro:~ Jack$ pod search AFNetworking
-> AFNetworking (3.1.0)
A delightful iOS and OS X networking framework.
pod 'AFNetworking', '~> 3.1.0'
- Homepage: https://github.com/AFNetworking/AFNetworking
- Source: https://github.com/AFNetworking/AFNetworking.git
- Versions: 3.1.0, 3.0.4, 3.0.3, 3.0.2, 3.0.1, 3.0.0, 3.0.0-beta.3,
3.0.0-beta.2, 3.0.0-beta.1, 2.6.3, 2.6.2, 2.6.1, 2.6.0, 2.5.4, 2.5.3, 2.5.2,
2.5.1, 2.5.0, 2.4.1, 2.4.0, 2.3.1, 2.3.0, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2.0,
2.1.0, 2.0.3, 2.0.2, 2.0.1, 2.0.0, 2.0.0-RC3, 2.0.0-RC2, 2.0.0-RC1, 1.3.4,
1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.2.1, 1.2.0, 1.1.0, 1.0.1, 1.0, 1.0RC3, 1.0RC2,
1.0RC1, 0.10.1, 0.10.0, 0.9.2, 0.9.1, 0.9.0, 0.7.0, 0.5.1 [master repo]
- Subspecs:
- AFNetworking/Serialization (3.1.0)
- AFNetworking/Security (3.1.0)
- AFNetworking/Reachability (3.1.0)
- AFNetworking/NSURLSession (3.1.0)
- AFNetworking/UIKit (3.1.0)
-> AFNetworking+AutoRetry (0.0.5)
Auto Retries for AFNetworking requests
pod 'AFNetworking+AutoRetry', '~> 0.0.5'
- Homepage: https://github.com/shaioz/AFNetworking-AutoRetry
终端中,cd到项目总目录(注意:包含PodTest文件夹、PodTest.xcodeproj、PodTestTest的那个总目录)
c 建立Podfile(配置文件)
接着上一步,终端输入 vim Podfile
在以上输入:
platform :ios, '8.0'
target '你的项目名称' do
pod 'AFNetworking', '~> 3.0'
end
然后:
shift+:wq 保存
pod install