19
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CocoaPods導入顛末

Last updated at Posted at 2013-01-06

はじめに

iOSアプリ作成で独自モジュールを作成した時、Archiveでのスタティックリンクライブラリの設定等で今まで苦労して来た。調べてみるとどうやらCocoaPodsという便利なしくみがあるらしい。これを導入する。環境はMac OSX 10.8.2。まずは一般的なライブラリを導入したいのでBlocksKitを導入する。

セットアップまで

ひとまず設定するまではホームディレクトリでも良いらしい。

sudo gem install cocoapods

gemは何もしなくても導入済みだったので上記…と思ったが、

sudo gem install cocoapods -V

としないと、結構時間がかかるので不安になる。これでcocoapods導入。セットアップ。

 $ pod setup
Your RubyGems version (1.8.24) is too old, please update with: `gem update --system`

と、怒られるのでアップデート。

 $ sudo gem update --system

無事にセットアップできる。

 $ pod setup
Setting up CocoaPods master repo
Cloning spec repo `master' from `https://github.com/CocoaPods/Specs.git' (branch `master')
Setup completed (read-only access)

Podfileの編集

とりあえず、既にworkspaceを導入済みだったので、workspace属性、xcodeproj属性を指定した。細かいところは下記を見ながら想像して設定。
http://rubydoc.info/gems/cocoapods/Pod/Podfile#platform-instance_method

platform :ios
dependency 'BlocksKit'
workspace 'XXXXX.xcworkspace'
xcodeproj 'YYYYY/YYYYY.xcodeproj'

試しにこれでやるとiOS4.3がどうたらこうたらと言われる。

 $ pod install
[DEPRECATED] `dependency' is deprecated (use `pod')
Resolving dependencies of `./Podfile'
Updating spec repositories
Resolving dependencies for target `default' (iOS 4.3)
[!] BlocksKit (1.8.1) is not compatible with iOS 4.3.

バージョン指定が必要なのだろう。platformにオプションがある事を発見する。下記のように修正。無事にPodプロジェクト、BlocksKit導入もできた。ここまで来ると手軽すぎる。

platform :ios, "5.0"
dependency 'BlocksKit'
workspace 'XXXXX.xcworkspace'
xcodeproj 'YYYYY/YYYYY.xcodeproj'

おしまいに

とても手軽なので、デフォルト導入して良い仕組みだと思った。BlocksKitも素晴らしいので是非お試しあれ。

参考

19
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?