1. 程式人生 > >Xcode brew安裝和使用

Xcode brew安裝和使用

開啟終端,輸入命令:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

根據提示完成安裝(有可能安裝失敗,將路徑修改為/usr/local/bin , 沒有失敗按照正常流程)

安裝結束後輸入 brew, 會出現相應的提示命令:

Example usage:

  brew [info | home | options ] [FORMULA...]

  brew install FORMULA...

  brew uninstall FORMULA...

  brew search [foo]

  brew list [FORMULA...]

  brew update

  brew upgrade [FORMULA...]

  brew pin/unpin [FORMULA...]

Troubleshooting:

  brew doctor

  brew install -vd FORMULA

  brew [--env | config]

Brewing:

  brew create [URL [--no-fetch]]

  brew edit [FORMULA...]

  https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Formula-Cookbook.md

Further help:

  man brew

  brew home

如此表示 brew 安裝成功,下一步安裝  carthage ,終端輸入命令:

brew install carthage

出現:

==> Downloading https://homebrew.bintray.com/bottles/carthage-0.15.2.el_capitan.

######################################################################## 100.0%

==> Pouring carthage-0.15.2.el_capitan.bottle.tar.gz

��  /usr/local/Cellar/carthage/0.15.2: 37 files, 11.9M

安裝成功,繼續輸入命令 carthage 出現

Available commands:

   archive           Archives built frameworks into a zip that Carthage can use

   bootstrap         Check out and build the project's dependencies

   build             Build the project's dependencies

   checkout          Check out the project's dependencies

   copy-frameworks   In a Run Script build phase, copies each framework specified by a SCRIPT_INPUT_FILE environment variable into the built app bundle

   fetch             Clones or fetches a Git repository ahead of time

   help              Display general or command-specific help

   update            Update and rebuild the project's dependencies

   version           Display the current version of Carthage

表示安裝成功.

在mac 某個目錄下新建一個資料夾取名 Carthage,終端進入該資料夾

cd /Users/XXXX/Carthage

終端輸入命令

vim Cartfile 

能生成一個Cartfile的檔案,輸入 i 進行編輯,輸入所需要的第三方庫例如: github "Alamofire/Alamofire" ~> 3.0 按 esc 退出,輸入冒號":",繼續輸入 wq 結束

終端輸入 

carthage update

出現

*** Cloning Alamofire

*** Checking outAlamofire at "3.3.0"

*** xcodebuild output can be found in/var/folders/bt/s3tsn68n7mg3x04fnhkxq7wm0000gn/T/carthage-xcodebuild.7U0poN.log

*** Building scheme"Alamofire OSX" in Alamofire.xcworkspace

*** Building scheme"Alamofire tvOS" in Alamofire.xcworkspace

*** Building scheme"Alamofire watchOS" in Alamofire.xcworkspace

*** Building scheme"Alamofire iOS" in Alamofire.xcworkspace

表示引用的第三方庫成功

將生成的 framework 引入所需要的工程中