從Xcode上cocoapods 第三方庫資源相依管理工具之安裝新版修正_RPC failed; curl 56 SSLRead() return error -9806 MiB/s_13次安裝失敗




歷經 13次安裝失敗  終於成功啦 !!! = =|||  感覺環境更新也大有問題


Cocoapods一詞如果是在進行ios開發等等相關的程式設計師,
絕對對此一詞不陌生。
它為一種支援Swift 和Objective-C 程式開發的第三方庫 資源相依性管理工具
其所在官方網站 : https://cocoapods.org/

每種程式語言在發展到某一階段後,通常就會出現相應的依賴管理工具

比方以下幾種程式語言對應的   
依賴管理工具(中央程式碼倉庫)

1
2
3
4
Ruby: gems
Python: pip
Java: maven
Nodejs: npm

開發iOS專案難免會需要使用第三方開源庫比方像  firebasegooglemap等等
CocoaPods的出現
使得我們可以節省設置/更新第三方開源庫的時間

更多link: 



cocoa跟cacao兩個英文單字的不同及文化緣由

在Google查詢圖片的時候,會看到一個像是果實種子植物的圖。
其實在英文讀音上,一開始我就感覺這是捨麼好吃的東西的feeling。

有種可口奶滋之類的酥脆口感,於是我開始嘗試陳列出有關於椰子、可可
等相關植物的英文,尋找它們的關聯。
因為我十分好奇當初它們幹麻要取名這種像食物的名字

Coconut  --->  椰子
Cacao  --->  可可豆(咖啡)
Cocoa powder ---> 可可粉
Cocoa butter ---> 可可脂


可可樹(學名:Theobroma cacao)  主要源自於南美(赤道南、北緯約20度)
為熱帶常綠植物/錦葵科
廣泛在非洲、東南亞和拉丁美洲種植


可可豆(可可亞豆): 可可樹長的果實裡面的種子
經加工處理完能作為 「可可餅」、「可可粉」、「可可脂」等食物原料。





Cacao and cocoa may sound similar, but both of them are unique when it comes to 
taste, nutrition, and cost. Sometimes , it can be used  to decorate cakes.

Cacao
Chocolate comes from the cacao tree.
Cacao is the purest form of chocolate you can consume, which means it is raw and much less processed than cocoa powder(可可粉) or chocolate bars. 

Cacao is thought to be the highest source of antioxidants (抗氧化劑) of all foods and the highest source of magnesium (鎂金屬元素) of all foods. 

It has been used throughout many cultures for years for health purposes and even used as a high trade commodity(有價值的物品/日用品).

Cocoa is the term used to refer to the heated form of cacao that you probably grew up buying at the store in the form of cocoa powder.

Cocoa powder is produced similarly to cacao except cocoa undergoes(to experience or to endure sth.) a higher temperature of heat during processing. 

Surprisingly, it still retains a large amount of antioxidants in the process and is still excellent for your heart, skin, blood pressure, and even your stress levels.


從字面上來看差異在於
cacao 未加工(天然)
cocoa 加工後(人工處理過後)

那在官網中 Cocoapods所推崇之理念為
"Get on with building your app, not duplicating code."

你想想看如果今天要你自己磨咖啡豆(從頭到尾)
花費好幾個小時
跟直接去超市買現成已經加工過的咖啡粉、咖啡包直接沖泡
是不是比較快呢!!!
這感覺是他們當初取名為   "Cocoapods"  的原因


於搜尋欄位中打上衣些特定功能的keyword都能查到
很多套裝工具(第三方庫)做使用





第一個問題.安裝時遇到問題

這裡我們要展示的是在安裝時遇到的問題排除



於不久前進行

cocoapods 第三方庫資源相依性管理工具
(支援Swift 和Objective-C )

10.11之後的Xcode 

在進行cocoapods安裝的時候

指令請從

sudo gem install cocoapods

修改為

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

不然舊版會出現
ERROR:  While executing gem ... (Errno::EPERM)

    Operation not permitted - /usr/bin/xcodeproj




第二個問題.
安裝指定的第三方套件FIrebase時候遇到中斷錯誤

這裡參考了Firebase官方網站去進行
套件安裝
Add Firebase to your iOS Project
https://firebase.google.com/docs/ios/setup
求:
Xcode : 7.3 or later for Swift
For Cloud Messaging : A physical iOS device


Step1.Create a Podfile if you don't have one

$ cd your-project directory
$ pod init

$ cd your-project directory
$ pod init

Step2. 
Add the pods that you want to install. You can include a Pod in your Podfile like this

pod 'Firebase/Core'
pod 'Firebase/Database'


Step3. Install the pods and open the .xcworkspace file

$ pod install
$ open your-project.xcworkspace

這裡你我可能遇到的錯誤問題
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `master`.
You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.




========================================================================
★問題生成的可能性有哪些??

Cocoapods   在安裝套件時候的指令為


$ sudo gem install cocoapods


gem  是一個跟 Ruby  軟體套件管理系統 有關的Package Manager 


全名又稱為   RubyGems     
(紅寶石管理)

創於2003年11月
目前最為穩定的版本為2年前(2015  2/16)的  2.4.6   

主要分為兩部分
1.gem指令
2.在 runtime中管理可用的 gems 與其版本

提供了分配發送
Ruby程式和函式庫的標準格式"gem"
主要是為了更方便管理gem安裝的工具,以及用於分發gem的server

在大陸,由於防火長城對Amazon S3的封鎖
因此使用官方網路server源頭進行安裝時
可能會長時間無響應
甚至回傳 "Connection reset by peer" 錯誤

因此在中國大陸可能需要更換軟體源才能正常使用Gem進行安裝

在 最原始官方網link:  https://rubygems.org/

在 大陸
有開發者朋友們提供資訊改為於 link: https://ruby.taobao.org/


在 Mac OS X 中, Ruby 的版本是 1.8.7  (預設有裝的話)

藉此  Cocoapods 

在 國外iOS開發工程師  Brian Voong
的示範影片中也可得知它和RVM及Ruby的相關連


藉此可推測   是系統環境更新或缺少某些部分安裝所導致的
安裝停滯


Reference link:

RubyGems─管理你的紅寶石

Swift: Firebase 3 - Installing SDK using Cocoapods and Saving Users into Database

========================================================================
Cocoapods  第三方套件安裝問題排除

Step1.  安裝 rvm

目的:讓你的環境可適應多種版本的Ruby
並可自行在多個版做適應性切換

使用  curl 指令(Linux 的一個強大 http 命令列工具)
命令行多協定支援服務器訪問工具
--->訪問RVM的 HTTP 伺服器


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




過程中又遇到新問題


這裡不要慌張
他的意思是指說需要你去該目錄檔案下編輯模式中
添加  source ~/.profile指令
目前讀不到導致無法進行  rvm的 安裝下載
所以先去 他所說的指定檔案目錄下的.bash_profile的檔案
去添加source ~/.profile


$ nano /Users/abraham/.bash_profile



之後再次去curl一次get.rvm.io
就可以了
預設網頁會顯示關於RVM(Ruby Version Manager)
的版本資訊
https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer


要檢查有沒有安裝成功就下




Step2.接著我們去
安裝一個ruby版本
MAC預設為2.0版 這裡更新下載
$ rvm install 2.2.2




很不幸地 !!!  又遇到一個Error

參考其他人提供資訊
https://www.laravist.com/discuss/github/install-homebrew-error-failed-during-git-fetch-origin-master-ref-1104


有時候是網路的問題等一會兒
再下一次指令又可以了 !!!  真詭異


檢查安裝之版本資訊指令

ruby版本
$ ruby -v

rvm(Ruby Version Manager)版本 
$ rvm -v


陳列出 已安裝的 Ruby 有哪些版本
$ rvm list




將目前的RVM設為預設版本


$ rvm use 2.2.2 --default




Step3.更換Server源頭

$ sudo gem update --system

刪除預設的gem原官方server源
換china源 試試看
陳列(list)出來


重新安裝Cocoapods


顯示版本(是否有安裝成功的確認)



最後再重新pod install   Firebase第三方庫
若失敗或中無又停了



就使用此指令查看
$ pod repo list


若輸出顯示為0 如下圖


代表未成功安裝

刪除掉  cocoapods 目錄 重下載pod 作更新

$ cd ~/.cocoapods/
$ sudo -rm -rf ~/.cocoapods/


後來依然不行安裝
參考了link
Unable to find a specification for `Firebase`

https://stackoverflow.com/questions/37771407/unable-to-find-a-specification-for-firebase

然後新錯誤又萌發了 = =|||
多災多難

Cocoapods: Unable to find a specification for `Firebase/Core`

https://stackoverflow.com/questions/40102061/cocoapods-unable-to-find-a-specification-for-firebase-core






[!] /usr/local/bin/git clone https://github.com/CocoaPods/Specs.git master --progress

Cloning into 'master'...
remote: Counting objects: 1316493, done.        
remote: Compressing objects: 100% (3958/3958), done.        
error: RPC failed; curl 56 SSLRead() return error -980630.00 KiB/s   
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed



RPC failed; curl 56 SSLRead() return error -9806 MiB/s

https://stackoverflow.com/questions/39939055/rpc-failed-curl-56-sslread-return-error-9806-mib-s


check git buffer


1
git config --global http.postBuffer 2M





建立一個新的 Repository

1
git init




Git 會告訴你


已經在此建立好一個新的 Git Repository



Clone(複製)別人的 Repository


出現ssl錯誤
無法使用git clone從github.com下載

錯誤訊息是
Cloning into 'master'...
remote: Counting objects: 1316511, done.
remote: Compressing objects: 100% (3987/3987), done.
error: RPC failed; curl 56 SSLRead() return error -9806 64.00 KiB/s    
fatal: The remote end hung up unexpectedly
fatal: early EOF

fatal: index-pack failed


可以使用此指令修正

1
git config http.sslVerify "false"






這裡我再次 pod repo remove 它

重新  setup後


回剛剛專案目錄  去針對已經指定好要裝
Firebase 套件的 Podfile文檔

執行  pod install  又可以了 !!!


這裡要先確認  你的pod 是否已經完整成功  Setup  喔!!!!
要看到綠色訊息才可以


最後用 pod repo list 指令再次確認





參考: 

cacao-vs-cocoa-what-you-need-to-know
http://www.onegreenplanet.org/vegan-food/cacao-vs-cocoa-what-you-need-to-know/

安装Cocoapods, 更新gem出现的问题。
https://segmentfault.com/q/1010000002926243

2016最新CocoaPods安裝和錯誤解決
http://www.jianshu.com/p/2ef8a38416c4

CocoaPods 簡介 : 如何輕鬆管理 Swift / Objective-C 的類庫
https://www.appcoda.com.tw/cocoapods/

Cannot install cocoa pods after uninstalling, results in error
https://stackoverflow.com/questions/30812777/cannot-install-cocoa-pods-after-uninstalling-results-in-error


用CocoaPods做iOS程序的依赖管理
http://blog.devtang.com/2014/05/25/use-cocoapod-to-manage-ios-lib-dependency/

How to Create a CocoaPod in Swift
https://www.raywenderlich.com/99386/create-cocoapod-swift


[Linux指令] curl的用法
http://charleslin74.pixnet.net/blog/post/419235508-%5Blinux%E6%8C%87%E4%BB%A4%5D-curl%E7%9A%84%E7%94%A8%E6%B3%95

cURL 指令用法與教學 http://www.ewdna.com/2012/04/curl_18.html

How to add pod file into your xcode project
https://www.youtube.com/watch?v=BSYLs0wl5ME


Git問題解決方法彙總
http://blog.sina.com.cn/s/blog_6b1ed4fb0101ixa3.html

git 想把檔案匯到某個存在的目錄下
http://carl830.pixnet.net/blog/post/61044299-git-%E6%83%B3%E6%8A%8A%E6%AA%94%E6%A1%88%E5%8C%AF%E5%88%B0%E6%9F%90%E5%80%8B%E5%AD%98%E5%9C%A8%E7%9A%84%E7%9B%AE%E9%8C%84%E4%B8%8B



How do I set GIT_SSL_NO_VERIFY for specific repos only?




留言

這個網誌中的熱門文章

經得起原始碼資安弱點掃描的程式設計習慣培養(五)_Missing HSTS Header

(2021年度)駕訓學科筆試準備題庫歸納分析_法規是非題

經得起原始碼資安弱點掃描的程式設計習慣培養(三)_7.Cross Site Scripting(XSS)_Stored XSS_Reflected XSS All Clients