使用CocoaPods管理Objective-C專案

CocoaPods載入Pod

之前的動作完成後,請關閉專案或退出Xcode,我們要建立CocoaPods環境,在此要另外說明的是,以CocoaPods建立的Library都統稱為Pods,後面會以Pods去稱呼。

開啟終端機到專案的目錄下:

ls -l
total 8
drwxr-xr-x  12 danny  staff  408  1 16 14:31 CocoaPodsDemo
drwxr-xr-x   5 danny  staff  170  1 16 14:54 CocoaPodsDemo.xcodeproj
drwxr-xr-x   5 danny  staff  170  1 16 14:31 CocoaPodsDemoTests
-rw-r--r--@  1 danny  staff   52  1 16 15:01 Podfile`

執行pod install

這個指令會讀取Podfile的設定並建立相應的環境:

Analyzing dependencies
Downloading dependencies
Installing AFNetworking (2.0.3)
Generating Pods project
Integrating client project

[!] From now on use `CocoaPodsDemo.xcworkspace`.
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.`

安裝完成後,CocoaPods會建立副檔名為.xcworkspace的工作檔案:

ls -l
total 16
drwxr-xr-x  12 danny  staff  408  1 16 14:31 CocoaPodsDemo
drwxr-xr-x   5 danny  staff  170  1 16 14:54 CocoaPodsDemo.xcodeproj
drwxr-xr-x   3 danny  staff  102  1 16 15:17 CocoaPodsDemo.xcworkspace
drwxr-xr-x   5 danny  staff  170  1 16 14:31 CocoaPodsDemoTests
-rw-r--r--@  1 danny  staff   52  1 16 15:01 Podfile
-rw-r--r--   1 danny  staff  740  1 16 15:17 Podfile.lock
drwxr-xr-x  17 danny  staff  578  1 16 15:17 Pods`