iOS アプリ開発において、外部ライブラリの管理をしたい。
CocoaPods というのが安定感ありそうだったので入れてみる。
CocoaPods を入れてうんぬんは簡単だが、そのあとに
CocoaPods でインストールしたライブラリを Xcode に認識させるという手順が必要になる模様。
CocoaPods インストール
$ gem install cocoapods
$ pod setup
Xcode プロジェクトに適用
$ cd /path/to/xcode_project
$ pod init
Podfile
が生成される。
$ vim Podfile
Podfile
の例
$ cat Podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
target 'KannaTest' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for KannaTest
pod 'Alamofire', '~> 4.4'
pod 'Kanna', '~> 2.1.0'
pod 'RxSwift', '~> 3.0'
pod 'RxCocoa', '~> 3.0'
target 'KannaTestTests' do
inherit! :search_paths
# Pods for testing
pod 'RxBlocking', '~> 3.0'
pod 'RxTest', '~> 3.0'
end
target 'KannaTestUITests' do
inherit! :search_paths
# Pods for testing
end
end
$ pod install
ライブラリがインストールされる。
ここでいったん Xcode プロジェクトを閉じる。
pod init
したときに、プロジェクト名.xcworkspace
というファイルができている。
これを Xcode で開く。
そうするとライブラリが導入された状態でプロジェクトが開かれる。
で、Xcode の Product
- Build
でビルドしなおす。
以上で、iOS アプリ開発で外部ライブラリを使うことができる。