iOS開發 Carthage安裝及使用

2021-08-08 17:18:46 字數 1747 閱讀 6487

1.使用homebrew安裝carthage之前,先對其進行更新,不然可能會安裝到比較老的版本。

sudo brew update

2.安裝carthage

3.檢視及公升級carthage版本

4.解除安裝carthage

sudo brew uninstall carthage

5.建立空的cartfile檔案

touch cartfile

6.使用xcode命令開啟cartfile檔案

open -a xcode cartfile

7.新增依賴庫

例:github "alamofire/alamofire" ~> 3.0

- 版本的含義:

~>3.0:表示使用版本3.0以上但是低於4.0的最新版本,如3.5, 3.9。

==3.0:表示使用3.0版本。

>=3.0:表示使用3.0或更高的版本。

如果你沒有指明版本號,則會自動使用最新的版本。

8.儲存並關閉cartfile檔案並執行carthage update

執行update命令後,你的專案目錄結構大致如下:

備註:

cartfile利用xcode-select命令來編譯framework,如果你想用其他版的xcode進行編譯,執行下面這條命令,把xcode-select的路徑改為另一版本xcode就可以。
9.引入framework
1. 設定xcode自動搜尋framework的目錄

target—>build setting—>framework search path—>新增路徑"$(srcroot)/carthage/build/ios"

2. 新增編譯的額外指令碼

target—>build phases —>」+」—>new run script phase—>新增指令碼"/usr/local/bin/carthage copy-frameworks"

3. 新增檔案

input files—>新增路徑"$(srcroot)/carthage/build/ios/庫名.framework"

以下是我安裝時出現的一些錯誤。

錯誤1:

error: could not symlink bin/carthage

/usr/local/bin is not writable.

解決方案:

sudo brew remove carthage

sudo brew install carthage

錯誤2:

warning: you are using os x 10.11.

we do not provide support for this pre-release version.

you may encounter build failures or other breakage.

解決方案:

sudo brew update

錯誤3:

Carthage 安裝與使用

1 安裝 在終端下執行 brew install carthage 複製 2 配置第三方類庫 到目標工程目錄下建立 carthage 檔案 在終端上用vim寫好要配置的庫資訊 vim cartfile 複製 3.執行 carthage update platform ios 僅編譯 ios 平台 複...

安裝和使用Carthage

0x01 首先安裝osx套件管理器homebrew ruby e curl fssl 0x02 使用 homebrew 進行安裝carthage 安裝之前先對homebrew進行更新一下 不然可能會安裝到比較老版本的carthage brew update 0x03 homebrew 安裝carth...

Carthage的簡單安裝和使用

使用 homebrew 進行安裝 brew update brew install carthage 第一步,在專案的根目錄下新建乙個無字尾的cartfile檔案 第二步,開啟命令終端,cd到所在專案目錄,執行 carthage update platform ios no use binaries...