LoginSignup
5

More than 5 years have passed since last update.

posted at

CocoaPodsなプロジェクトで複数ブランチを行き来する際に"sandbox is not in sync"でイライラしない方法

複数人で開発を行っていると、ライブラリの追加やアップデート等でブランチ間のPodfileに差分が生じる事がある。
コードレビュー等のためにブランチ間を行き来していると、XCodeビルドを走らせてからこのようなエラーが出てpod installが必要と気づく事が多い。

error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

できればブランチを切り替えた際必要に応じて自動でpod installしたい。

とか考えてたが、超単純にGitのpost-checkoutでPodfile.lockと${PODS_ROOT}/Manifest.lockのdiffを見ればいいだけだった。

.git/hooks/post-checkout
diff Podfile.lock Pods/Manifest.lock > /dev/null
if [[ $? != 0 ]]; then
  echo "Sandbox needs to be updated. Re-installing libraries..."
  bundle exec pod install
fi

これでチェックアウト先でpodsの再インストールが必要であればpod installが開始される。

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
What you can do with signing up
5