2015年5月17日日曜日

CocoaPodsを使ってAFNetworkingを導入する

導入対象プロジェクト(今回の場合はPodsSample.xcodeproj)は閉じておく。
プロジェクトファイルがあるディレクトリまで移動後、Podfileを生成する。
$ cd /path/to/PodsSample
$ pod init

Podfileを編集する。
$ open -a Xcode Podfile

Podfile
# Uncomment this line to define a global platform for your project
# platform :ios, '6.0'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'PodsSample' do
  pod 'AFNetworking', '~>2.5.3'
end

target 'PodsSampleTests' do

end


Podfileを保存して閉じた後、pod installを実行する。
$ rm Podfile.lock
$ pod install --verbose

以降は常にプロジェクトではなく、ワークスペースを開いて使う。
$ ls -l
(下記は抜粋表示)
Podfile
Podfile.lock
Pods
PodsSample
PodsSample.xcodeproj
PodsSample.xcworkspace
PodsSampleTests

$ open PodsSample.xcworkspace


CocoaPods管理のライブラリを更新する際は下記を実行する。
$ pod update


0 件のコメント:

コメントを投稿