LoginSignup
30
24

More than 5 years have passed since last update.

複数のターゲットに同じPodをインストールする場合のBest Practice

Last updated at Posted at 2016-01-04

新年仕事始めしたらcocoapodsの新しいのが出てたのでインストールしてみたら怒られた。

[!] The dependency `Google` is not used in any concrete target.

Stackoverflow曰く、ちゃんとTargetsを書かないとイカンらしい。(考える前にググる派)

さて、私のプロジェクトは同じコードベースで複数のTargetにビルドしているので、バカっぽく書くと

target "A" do
  # 20行ぐらいのpods
end

target "B" do
  # 上と同じpods
end

target "C" do
  # 上と同じpods
end

みたいな感じで馬鹿っぽい。

どうしたもんかな、と思ってたのだけど、PodfileはただのRubyなので、podのところは関数にしてまとめちゃえる。
Python脳なので、Ruby感がわからなかったが、Natashaさんのブログを参考にした。

def install_pods
  # 20行ぐらいのpods
end

target "A" do
  install_pods
end

target "B" do
  install_pods
end

target "C" do
  install_pods
end

これでちょっとはましになった。

30
24
2

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
30
24