15
15

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.

gitのブランチを切り替えたらpod install

Last updated at Posted at 2014-09-05

チームでiOSアプリを開発している人たちはブランチ変更するたびに手動でpod installしていて、苛つくことがよくあるかと思います。そんな時にはgitのpost-checkoutフックを利用してブランチを切り替えるごとにpod installを実行するようにすると良いかと思います。

以下の設定を.git/hooks/以下のpost-checkoutファイルに書いてchmod +x post-checkoutしておけばブランチ切り替えごとにPodfileの更新があれば自動的にpod installするようになります。

/path/to/ios-project/.git/hooks/post-checkout
#!/bin/sh

# parse this format
# x3de1b0 HEAD@{0}: checkout: moving from xxxx to yyyyy
BEFORE_BRANCH=`git reflog | head -1 | cut -f 6 -d ' '`
AFTER_BRANCH=`git reflog | head -1 | cut -f 8 -d ' '`
DIFF=`git diff ${BEFORE_BRANCH} ${AFTER_BRANCH} --name-only | grep Podfile`

if [ -n "${DIFF}" ]; then
  bundle exec pod install
fi

便利

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?