cocoapods安裝、安裝中可能遇到問題以及使用

在osx 10.11之前cocopods問題不多,但是升級到11之後的版本,之前的cocopods大多用不了,需要重新安裝,對於我這種使用測試版系統的技術狂來說,每次都需要重新安裝很多東西,

當然,cocopods也避免不了安裝很多次了。

       對於新手來說,使用cocopods開發,還是節省了相當多的開發時間,以下便是cocopods安裝和安裝過程中遇到的問題及解決辦法:

 

 
 
【注:可以直接從第二步開始安裝】
2、出現以下問題,大家不要慌:
 
複製代碼
1 boai:~ boai$ sudo gem install cocoapods
2 ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
3           Unable to download data from http://ruby.taobao.org/ - bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
4 boai:~ boai$ sudo gem install cocoapods 
5 ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
6           Unable to download data from http://ruby.taobao.org/ - bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
7 boai:~ boai$ sudo gem update --system
8 ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
9     bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
複製代碼

解決辦法:

(1)先執行下面兩行代碼:

1 sudo gem sources -r https://rubygems.org

2 sudo gem sources -a http://rubygems.org 

(2)執行過程如下:

1 boai:~ boai$ sudo gem sources -r https://rubygems.org
2 source https://rubygems.org not present in cache
3 boai:~ boai$ sudo gem sources -a http://rubygems.org
4 https://rubygems.org is recommended for security over http://rubygems.org
5 
6 Do you want to add this insecure source? [yn]  y

最後會提示

Do you want to add this insecure source? [yn]  
你選擇 y就行了
然後出現:
http://rubygems.org added to sources

這就說明成功了,就可以執行下面的安裝了。

 

在2016年7月1日開始,會出現以下錯誤,

 

rvm: command not found Mac

activesupport requires Ruby version >= 2.2.2.

 

這兩種錯誤的解決辦法如下;

 

強烈建議 使用rvm安裝ruby

1、安裝 RVM

RVM:Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem庫管理(gemset)

  1. $ curl -L get.rvm.io | bash -s stable  

等待一段時間後就可以成功安裝好 RVM。

  1. $ source ~/.bashrc  
  2. $ source ~/.bash_profile 

測試是否安裝正常

 rvm -v 

 2、用RVM升級Ruby
  1. #查看當前ruby版本  
  2. $ ruby -v  
  3. ruby 1.8.7  
  4. #列出已知的ruby版本  
  5. $ rvm list known  
  6. #安裝ruby 2.3.0  
  7. boaideMacBook:~ boai$ rvm install 2.3.0

期間會讓你輸入兩次回車鍵,記得哦,別像我一樣傻等了半天,以爲網卡呢, 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
boaideMacBook:~ boai$ rvm install 2.3.0
Searching forbinary rubies, thismight take some time.
No binary rubies availablefor: osx/10.11/x86_64/ruby-2.3.0.
Continuing with compilation. Please read'rvm help mount' to get more information on binary rubies.
Checking requirementsfor osx.
About to install Homebrew, press `Enter`for defaultinstallation in `/usr/local`,
type newpath if you wish custom Homebrew installation (the path needs to be writable foruser)
:
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
==> The following directories will be made group writable:
/usr/local/.
==> The following directories will have their owner set to boai:
/usr/local/.
==> The following directories will have their group set to admin:
/usr/local/.
 
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/.
Password:
==> /usr/bin/sudo /usr/sbin/chown boai /usr/local/.
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/.
==> /usr/bin/sudo /bin/mkdir /Users/boai/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/boai/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown boai /Users/boai/Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 520, done.
remote: Compressing objects: 100% (461/461), done.
remote: Total 520 (delta 30), reused 318 (delta 28), pack-reused 0
Receiving objects: 100% (520/520), 786.43 KiB | 146.00 KiB/s, done.
Resolving deltas: 100% (30/30), done.
From https://github.com/Homebrew/brew
 * [newbranch]      master     -> origin/master
HEAD is now at 5768e32 test-bot: fix coverage on Travis CI
==> Tapping homebrew/core
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 3718, done.
remote: Compressing objects: 100% (3605/3605), done.
remote: Total 3718 (delta 7), reused 2085 (delta 4), pack-reused 0
Receiving objects: 100% (3718/3718), 2.89 MiB | 521.00 KiB/s, done.
Resolving deltas: 100% (7/7), done.
Checking connectivity... done.
Tapped 3596 formulae (3,744 files, 9.0M)
==> Installation successful!
==> Next steps
Run `brew help` to get started
Further documentation: https://git.io/brew-docs
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here:
  https://git.io/brew-analytics
Installing requirementsfor osx.
Updating system.....
Installing required packages: autoconf, automake, libtool, pkg-config, libyaml, readline, libksba, openssl........
Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/boai/.rvm/rubies/ruby-2.3.0,this may take awhile depending on your cpu(s)...
ruby-2.3.0 - #downloading ruby-2.3.0,this may take awhile depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.5M  100 13.5M    0     0  3078k      0  0:00:04  0:00:04 --:--:-- 3477k
ruby-2.3.0 - #extracting ruby-2.3.0 to /Users/boai/.rvm/src/ruby-2.3.0....
ruby-2.3.0 - #configuring....................................................

 

 時間比較長:

 安裝成功後提示:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
ruby-2.3.0 - #downloading ruby-2.3.0,this may take awhile depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.5M  100 13.5M    0     0  3078k      0  0:00:04  0:00:04 --:--:-- 3477k
ruby-2.3.0 - #extracting ruby-2.3.0 to /Users/boai/.rvm/src/ruby-2.3.0....
ruby-2.3.0 - #configuring......................................................|
ruby-2.3.0 - #post-configuration.
ruby-2.3.0 - #compiling........................................................|
ruby-2.3.0 - #installing.........
ruby-2.3.0 - #making binaries executable..
Installed rubygems 2.5.1 is newer than 2.4.8 provided with installed ruby, skipping installation, use --force to force installation.
ruby-2.3.0 - #gemset created /Users/boai/.rvm/gems/ruby-2.3.0@global
ruby-2.3.0 - #importing gemset /Users/boai/.rvm/gemsets/global.gems............|
ruby-2.3.0 - #generating global wrappers........
ruby-2.3.0 - #gemset created /Users/boai/.rvm/gems/ruby-2.3.0
ruby-2.3.0 - #importing gemsetfile /Users/boai/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.3.0 - #generatingdefault wrappers........
ruby-2.3.0 - #adjusting #shebangsfor (gem irb erb ri rdoc testrb rake).
Install of ruby-2.3.0 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
boaideMacBook:~ boai$

 

 

 

 然後再執行這句代碼:

1 boai:~ boai$ sudo gem install cocoapods

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
boaideMacBook:~ boai$ sudo gem install cocoapods
Password:
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: thread_safe-0.3.5.gem (100%)
Successfully installed thread_safe-0.3.5
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: concurrent-ruby-1.0.2.gem (100%)
Successfully installed concurrent-ruby-1.0.2
Fetching: activesupport-5.0.0.gem (100%)
Successfully installed activesupport-5.0.0
Fetching: nap-1.1.0.gem (100%)
Successfully installed nap-1.1.0
Fetching: fuzzy_match-2.0.4.gem (100%)
Successfully installed fuzzy_match-2.0.4
Fetching: cocoapods-core-1.0.1.gem (100%)
Successfully installed cocoapods-core-1.0.1
Fetching: claide-1.0.0.gem (100%)
Successfully installed claide-1.0.0
Fetching: cocoapods-deintegrate-1.0.0.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.0
Fetching: cocoapods-downloader-1.1.0.gem (100%)
Successfully installed cocoapods-downloader-1.1.0
Fetching: cocoapods-plugins-1.0.0.gem (100%)
Successfully installed cocoapods-plugins-1.0.0
Fetching: cocoapods-search-1.0.0.gem (100%)
Successfully installed cocoapods-search-1.0.0
Fetching: cocoapods-stats-1.0.0.gem (100%)
Successfully installed cocoapods-stats-1.0.0
Fetching: netrc-0.7.8.gem (100%)
Successfully installed netrc-0.7.8
Fetching: cocoapods-trunk-1.0.0.gem (100%)
Successfully installed cocoapods-trunk-1.0.0
Fetching: cocoapods-try-1.1.0.gem (100%)
Successfully installed cocoapods-try-1.1.0
Fetching: molinillo-0.4.5.gem (100%)
Successfully installed molinillo-0.4.5
Fetching: colored-1.2.gem (100%)
Successfully installed colored-1.2
Fetching: xcodeproj-1.2.0.gem (100%)
Successfully installed xcodeproj-1.2.0
Fetching: escape-0.0.4.gem (100%)
Successfully installed escape-0.0.4
Fetching: fourflusher-0.3.2.gem (100%)
Successfully installed fourflusher-0.3.2
Fetching: cocoapods-1.0.1.gem (100%)
Successfully installed cocoapods-1.0.1
Parsing documentationfor i18n-0.7.0
Installing ri documentationfor i18n-0.7.0
Parsing documentationfor thread_safe-0.3.5
Installing ri documentationfor thread_safe-0.3.5
Parsing documentationfor tzinfo-1.2.2
Installing ri documentationfor tzinfo-1.2.2
Parsing documentationfor concurrent-ruby-1.0.2
Installing ri documentationfor concurrent-ruby-1.0.2
Parsing documentationfor activesupport-5.0.0
Installing ri documentationfor activesupport-5.0.0
Parsing documentationfor nap-1.1.0
Installing ri documentationfor nap-1.1.0
Parsing documentationfor fuzzy_match-2.0.4
Installing ri documentationfor fuzzy_match-2.0.4
Parsing documentationfor cocoapods-core-1.0.1
Installing ri documentationfor cocoapods-core-1.0.1
Parsing documentationfor claide-1.0.0
Installing ri documentationfor claide-1.0.0
Parsing documentationfor cocoapods-deintegrate-1.0.0
Installing ri documentationfor cocoapods-deintegrate-1.0.0
Parsing documentationfor cocoapods-downloader-1.1.0
Installing ri documentationfor cocoapods-downloader-1.1.0
Parsing documentationfor cocoapods-plugins-1.0.0
Installing ri documentationfor cocoapods-plugins-1.0.0
Parsing documentationfor cocoapods-search-1.0.0
Installing ri documentationfor cocoapods-search-1.0.0
Parsing documentationfor cocoapods-stats-1.0.0
Installing ri documentationfor cocoapods-stats-1.0.0
Parsing documentationfor netrc-0.7.8
Installing ri documentationfor netrc-0.7.8
Parsing documentationfor cocoapods-trunk-1.0.0
Installing ri documentationfor cocoapods-trunk-1.0.0
Parsing documentationfor cocoapods-try-1.1.0
Installing ri documentationfor cocoapods-try-1.1.0
Parsing documentationfor molinillo-0.4.5
Installing ri documentationfor molinillo-0.4.5
Parsing documentationfor colored-1.2
Installing ri documentationfor colored-1.2
Parsing documentationfor xcodeproj-1.2.0
Installing ri documentationfor xcodeproj-1.2.0
Parsing documentationfor escape-0.0.4
Installing ri documentationfor escape-0.0.4
Parsing documentationfor fourflusher-0.3.2
Installing ri documentationfor fourflusher-0.3.2
Parsing documentationfor cocoapods-1.0.1
Installing ri documentationfor cocoapods-1.0.1
Done installing documentationfor i18n, thread_safe, tzinfo, concurrent-ruby, activesupport, nap, fuzzy_match, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, netrc, cocoapods-trunk, cocoapods-try, molinillo, colored, xcodeproj, escape, fourflusher, cocoapods after 24 seconds
23 gems installed
boaideMacBook:~ boai$

 

 這就代表安裝成功了!

 

3、安裝cocopods

執行下面的語句:

 1 sudo gem install cocoapods 

據說新版本改了,沒有驗證,大家可以試試看:

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

 

會出現下面的界面:(激動。。。)

複製代碼
boai:~ boai$ sudo gem install cocoapods
Fetching: nap-1.0.0.gem (100%)
Successfully installed nap-1.0.0
Fetching: thread_safe-0.3.5.gem (100%)
Successfully installed thread_safe-0.3.5
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: activesupport-4.2.5.gem (100%)
Successfully installed activesupport-4.2.5
Fetching: escape-0.0.4.gem (100%)
Successfully installed escape-0.0.4
Fetching: colored-1.2.gem (100%)
Successfully installed colored-1.2
Fetching: molinillo-0.4.0.gem (100%)
Successfully installed molinillo-0.4.0
Fetching: netrc-0.7.8.gem (100%)
Successfully installed netrc-0.7.8
Fetching: cocoapods-trunk-0.6.4.gem (100%)
Successfully installed cocoapods-trunk-0.6.4
Fetching: cocoapods-try-0.5.1.gem (100%)
Successfully installed cocoapods-try-0.5.1
Fetching: cocoapods-stats-0.6.2.gem (100%)
Successfully installed cocoapods-stats-0.6.2
Fetching: cocoapods-search-0.1.0.gem (100%)
Successfully installed cocoapods-search-0.1.0
Fetching: cocoapods-plugins-0.4.2.gem (100%)
Successfully installed cocoapods-plugins-0.4.2
Fetching: cocoapods-downloader-0.9.3.gem (100%)
Successfully installed cocoapods-downloader-0.9.3
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: fuzzy_match-2.0.4.gem (100%)
Successfully installed fuzzy_match-2.0.4
Fetching: cocoapods-core-0.39.0.gem (100%)
Successfully installed cocoapods-core-0.39.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 thread_safe-0.3.5
Installing ri documentation for thread_safe-0.3.5
Parsing documentation for tzinfo-1.2.2
Installing ri documentation for tzinfo-1.2.2
Parsing documentation for i18n-0.7.0
Installing ri documentation for i18n-0.7.0
Parsing documentation for activesupport-4.2.5
Installing ri documentation for activesupport-4.2.5
Parsing documentation for escape-0.0.4
Installing ri documentation for escape-0.0.4
Parsing documentation for colored-1.2
Installing ri documentation for colored-1.2
Parsing documentation for molinillo-0.4.0
Installing ri documentation for molinillo-0.4.0
Parsing documentation for netrc-0.7.8
Installing ri documentation for netrc-0.7.8
Parsing documentation for cocoapods-trunk-0.6.4
Installing ri documentation for cocoapods-trunk-0.6.4
Parsing documentation for cocoapods-try-0.5.1
Installing ri documentation for cocoapods-try-0.5.1
Parsing documentation for cocoapods-stats-0.6.2
Installing ri documentation for cocoapods-stats-0.6.2
Parsing documentation for cocoapods-search-0.1.0
Installing ri documentation for cocoapods-search-0.1.0
Parsing documentation for cocoapods-plugins-0.4.2
Installing ri documentation for cocoapods-plugins-0.4.2
Parsing documentation for cocoapods-downloader-0.9.3
Installing ri documentation for cocoapods-downloader-0.9.3
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 fuzzy_match-2.0.4
Installing ri documentation for fuzzy_match-2.0.4
Parsing documentation for cocoapods-core-0.39.0
Installing ri documentation for cocoapods-core-0.39.0
Parsing documentation for cocoapods-0.39.0
Installing ri documentation for cocoapods-0.39.0
Done installing documentation for nap, thread_safe, tzinfo, i18n, activesupport, escape, colored, molinillo, netrc, cocoapods-trunk, cocoapods-try, cocoapods-stats, cocoapods-search, cocoapods-plugins, cocoapods-downloader, claide, xcodeproj, fuzzy_match, cocoapods-core, cocoapods after 21 seconds
WARNING:  Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
20 gems installed
複製代碼

看到最後一行代碼,你就放120個心吧。。。

 

然後就可以查看你的pods版本了:

輸入:pod

然後會出現下面的代碼:

複製代碼
boai:~ boai$ pod
Usage:

    $ pod COMMAND

      CocoaPods, the Cocoa library package manager.

Commands:

    + cache      Manipulate the CocoaPods cache
    + init       Generate a Podfile for the current directory.
    + install    Install project dependencies to Podfile.lock versions
    + ipc        Inter-process communication
    + lib        Develop pods
    + list       List pods
    + outdated   Show outdated project dependencies
    + plugins    Show available CocoaPods plugins
    + repo       Manage spec-repositories
    + search     Search for pods.
    + setup      Setup the CocoaPods environment
    + spec       Manage pod specs
    + trunk      Interact with the CocoaPods API (e.g. publishing new specs)
    + try        Try a Pod!
    + update     Update outdated project dependencies and create new
                 Podfile.lock

Options:

    --silent     Show nothing
    --version    Show the version of the tool
    --verbose    Show more debugging information
    --no-ansi    Show output without ANSI codes
    --help       Show help banner of specified command
boai:~ boai$ 
複製代碼

 

這就安裝成功了,就可以正常使用pod了。。。

 

4、接下來就可以在項目中使用了,

打開終端:

cd 你的項目路徑

boai:~ boai$ cd /Users/boai/Documents/博愛項目/BAPDCViewTest 

然後:輸入touch podfile  或者 pod init (會自動生成podfile文件)

boai:BAPDCViewTest boai$ pod init

boai:BAPDCViewTest boai$ pod install

接下來出現:

複製代碼
Last login: Fri Nov 20 11:02:59 on ttys006

boai:~ boai$ cd /Users/boai/Documents/博愛項目/BAPDCViewTest 

boai:BAPDCViewTest boai$ touch podfile

boai:BAPDCViewTest boai$ pod install

Updating local specs repositories

Analyzing dependencies

Downloading dependencies

Generating Pods project

Integrating client project

 

[!] Please close any current Xcode sessions and use `BAPDCViewTest.xcworkspace` for this project from now on.

Sending stats

Pod installation complete! There are 0 dependencies from the Podfile and 0 total

pods installed.

 

[!] [!] The Podfile does not contain any dependencies.

boai:BAPDCViewTest boai$ 

 
複製代碼

 

這就成功了,然後再看看你的項目路徑裏面,是不是多出來很多文件?

如下圖:

 

 

然後雙擊***.workspace 文件就可以使用pods了!

 

5、新版本pod 安裝問題:

podfile升級之後到最新版本,pod裏的內容必須明確指出所用第三方庫的target,否則會出現The dependency `` is not used in any concrete target這樣的錯誤。

以下從三個步驟陳述:

4.1. Podfile升級

查看pod版本:

1
pod --version

 pod 升級(此時是升級到1.0.0.beta.2版本):

1
sudo gem install cocoapods --pre

 

4.2. 錯誤內容:

我的Podfile的內容是:

1
pod ‘SDWebImage‘, ‘3.6‘

 

pod install後出現錯誤The dependency `` is not used in any concrete target

1
2
3
4
5
6
7
8
pod install
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin14/rbconfig.rb:213: warning: Insecure world writable dir /Applications/Cocos/tools/ant/bin in PATH, mode 040777
Re-creating CocoaPods due to major version update.
Updating local specs repositories
Analyzing dependencies
 
 
The dependency `SDWebImage (= 3.6)` is not used in any concrete target.

 

4.3. 修改方法:

Podfile內容更改:

步驟:

4.3.1 雙擊雙擊***.workspace 文件,打開項目

4.3.2 拉到最下面,找到pods,打開後點擊podfile文件,

4.3.3 在podfile裏面添加所需要的三方庫

最終的podfile 文件規範內容爲下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!<br><br># 注意:xcodeproj '***.xcodeproj'  這句新版本必須要寫上,***爲你的工程名字,最下面記得要加上  @end
xcodeproj 'BABaseProject.xcodeproj'
 
 
# 去掉由pod引入的第三方庫的警告,需要更新命令才生效
inhibit_all_warnings!
 
target 'BABaseProject'do
     
    # 對系統原生的AutoLayout 的 NSLayoutConstraints類的封裝,優雅的鏈式語法,GitHub 排名第三
    pod'Masonry', '~> 0.6.4'
    # 兩個都是自動佈局框架
    pod'SDAutoLayout', '~> 1.31'
 
    # 自定義button框架
    pod'BAButton', '~> 1.0.1'
 
end
 
target 'BABaseProjectTests'do
     
end
 
target 'BABaseProjectUITests'do
     
end

 

 

 4.3.4 完成podfile 的內容更改後,記得 cmd + s 保存更改,然後打開終端

4.3.5  在終端中cd 項目路徑,打開項目後,輸入: 

1
2
3
4
5
6
7
8
9
pod install --verbose --no-repo-update
 
pod update --verbose --no-repo-update
 
或者
 
pod install --no-repo-update
 
pod update --no-repo-update

 

然後看你的項目路徑pod下面, 是不是已經添加了你所需要的三方庫呢?

 

如果更新pod 的時候出現這個問題:

安裝cocoapods遇到error: RPC failed; curl 56 SSLRead() return error -36問題

解決辦法如下:終端輸入以下代碼:

<code
 class="hljs cs has-numbering"style="display: block; padding: 0px;
background-color: transparent; color: inherit; box-sizing: border-box;
font-family: 'Source Code Pro', monospace;font-size:undefined;
white-space: pre; border-top-left-radius: 0px; border-top-right-radius:
0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px;
word-wrap: normal; background-position: initial initial;
background-repeat: initial initial;">sudo xcode-<span
class="hljs-keyword"style="color: rgb(0, 0, 136); box-sizing:
border-box;">select</span> -<span class="hljs-keyword"
style="color: rgb(0, 0, 136); box-sizing:
border-box;">switch</span>
/Applications/Xcode.app/Contents/Developers</code><ul
class="pre-numbering"style="box-sizing: border-box; position: absolute;
 width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px;
 margin: 0px; padding: 6px 0px 40px; border-right-width: 1px;
border-right-style: solid; border-right-color: rgb(221, 221, 221);
list-style: none; text-align: right;"><li style="box-sizing:
border-box; padding: 0px 5px;">1</li></ul><ul
class="pre-numbering"style="box-sizing: border-box; position: absolute;
 width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px;
 margin: 0px; padding: 6px 0px 40px; border-right-width: 1px;
border-right-style: solid; border-right-color: rgb(221, 221, 221);
list-style: none; text-align: right;"><li style="box-sizing:
border-box; padding: 0px 5px;">1</li></ul>

 

然後再更新pod試試!

 

如果出現這個:

1
[!] xcodeproj was renamed to `project`. Please use that from now on.

 只需要將這裏的名字改過來就行了:

複製代碼
 1 # Uncomment this line to define a global platform for your project
 2 # platform :ios, '8.0'
 3 # Uncomment this line if you're using Swift
 4 # use_frameworks!
 5 
 6 project 'BABaseProject.project'
 7 
 8 
 9 # 去掉由pod引入的第三方庫的警告,需要更新命令才生效
10 inhibit_all_warnings!
11 
12 # pod 快速更新方法
13 # pod update --verbose --no-repo-update
14 
15 target 'BABaseProject' do
複製代碼

 

 

 

5、最後給大家點推薦內容:

 

5.1、一個基於 MVVM 和 MVC 設計模式的基本項目框架,項目用到的各種類,各種封裝,各種三方庫的綜合項目,歡迎大家使用!

有了『BABaseProject』一個基於 MVVM 和 MVC 設計模式的基本項目框架,以後開發項目再也不用擔心自己搭建框架了!

 

5.2、完全實現『UIButton』的自定義的類庫

發佈了175 篇原創文章 · 獲贊 34 · 訪問量 27萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章