CocoaPods安裝備忘

2021-06-28 15:33:15 字數 1957 閱讀 6963

(網上說cocoapods.org被禁用了(得*牆才行),第一步前得加幾步才行,不過我直接從第一步開始是沒問題的,可能已經放開能用了,不過還是把操作說一下吧)

步驟如下:用**的ruby映象來訪問cocoapods

$ gem sources --remove 

//等有反應之後再敲入以下命令

$ gem sources -a

為了驗證你的ruby映象是並且僅是taobao,可以用以下命令檢視:

$ gem sources -l
只有在終端中出現下面文字才表明你上面的命令是成功的:

*** current sources ***

然後就可以繼續了

第一步、

sudo gem install cocoapods

$ pod setup

第三部、

新增第三方庫(新增afnetworking)

為了確定afnetworking是否支援cocoapods,可以用cocoapods的搜尋功能驗證一下。在終端中輸入:

$ pod search afnetworking
然後各種afnetworking就出來了,說明支援該庫

第四步、

我們先建立這個神奇的podfile。在終端中進入(cd命令)你專案所在目錄,然後在當前目錄下,利用vim建立podfile,

執行:

$ vim podfile
然後在podfile檔案中輸入以下文字:

source ''

pod 'afnetworking','~> 2.5.0'

這時候,你會發現你的專案目錄中,出現乙個名字為podfile的檔案,而且檔案內容就是你剛剛輸入的內容。注意,podfile檔案應該和你的工程檔案.xcodeproj在同乙個目錄下。

老版本是下面的內容,已經被拋棄

platform :ios, '7.0'

pod "afnetworking", '~> 2.0'

第四步也可以用命令touch podfile然後在專案目錄下面生成的podfile直接進行文字編輯,加上上面的內容即可

這裡千萬注意,

格式一定要正確,比如乙個單引號,一定要用英文的單引號等等

第五步、

$ pod install
因為是在你的專案中匯入afnetworking,這就是為什麼這個命令需要你進入你的專案所在目錄中執行。

執行上述命令之後,終端出現以下資訊:

ericmatomacbook-pro:cocoapodsdemo ericwang$ pod install

analyzing dependencies

downloading dependencies

installing afnetworking (2.0.2)

generating pods project

integrating client project

[!] from now on use `cocoapodsdemo.xcworkspace`.

注意最後一句話,意思是:以後開啟專案就用 cocoapodsdemo.xcworkspace 開啟,而不是之前的.xcodeproj檔案。

這個時候應該專案裡面可以用庫了

下面說說後續用到的操作

第六步、

需要新的庫,這個時候不需要新建podfile了,cd 到專案目錄

$ pod update
就可以了,

第七步、

$ pod update
即可

vss 安裝備忘

安裝6.0時,必須轉換um.dat格式 to build a new um.dat file,follow these steps 1.create a temporary folder named c sstemp.2.clickstart,clickrun,type cmd,and then c...

msyql php 安裝備忘

1 安裝mysql 啟動 mysqld safe 如果報錯,檢視 etc my.cnf檢視mysql配置,找到log檔案,檢視出錯日誌。如果錯誤為 error fatal error can t open and lock privilege tables table mysql.host does...

debian安裝備忘

感謝同事alex的指點,隨寫一下備忘。1 etc apt sources.list 增加 deb testing main contrib non free deb src testing main contrib non free deb sid main contrib non free deb...