LoginSignup
5
5

More than 5 years have passed since last update.

podコマンドのバージョン固定

Posted at

CocoaPodsのインストールといえば

$ gem install cocoapods

って書いてある事が多い。

これだと

  • 複数人で開発する時に別々のバージョンが入る事がある
  • そのせいで、Podfile.lockに差分が出る

という事故がたまーに起きる。

なので、

$ gem install cocoapods -v x.x.x

という感じで指定する。

でも、別のプロジェクトだとバージョンが違うとか起こる…。

というわけで、僕はbundlerを使って入れています。

bundlerを使う

bundleを使っておけば、CocoaPods以外に使いたいgemが出てきてもGemfileに追加すれば良いので便利。

とか。

bundlerのインストール

$ gem install bundler

Gemfile作成

$ cd $PROJECT_ROOT
$ cat > Gemfile <<EOD
source 'https://rubygems.org'

gem 'cocoapods'

<<EOD
  • 任意のバージョンで固定したい場合
$ gem 'cocoapods', '0.33.1'

とか書く。

bundle install

$ cd $PROJECT_ROOT
$ bundle install --path=vendor/bundle --binstubs=vendor/bundle/bin

pod install

  • Podfileを用意してから
$ cd $PROJECT_ROOT
$ bundle exec pod install

おまけ

direnvを入れておくとbundle execが要らなくなって便利

install

$ brew install direnv
  • Hookの登録
~/.zshrc
eval "$(direnv hook zsh)"

設定

$ cd $PROJECT_ROOT
$ cat > .envrc <<EOD
export PATH=$PWD/vendor/bundle/bin:$PATH
EOD
$ direnv allow

これで、PROJECT_ROOTcdすれば

pod install

と使えるようになる。

5
5
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
5
5