BLOGサブスレッドの日常

2016.07.08

CocoaPodsでpod updateしようとして失敗する場合

chao

はじめに

金曜担当のしみずです。どうぞよろしく。

別ネタが入ったので、先週のBB-8を動かすネタはひとまずお休みします。
過去のXcodeのプロジェクトでCocoaPodsが使われているものがあったのですが
それをpod updateしたらエラーが出たので、その事を書いていきます。

手元の環境

Xcode 7.3
CocoaPods 1.0.1

pod update をすると失敗する

Podfileは以下のようになっています。

platform :ios, '8.0'
pod 'AFNetworking'

この状態で pod update を行うと

$ pod update
Update all pods
Updating local specs repositories
Analyzing dependencies
[!] The dependency `AFNetworking` is not used in any concrete target.

エラーが出てしまいます。

解決方法

公式サイト(https://cocoapods.org/) で書き方を見ると



target 'MyApp' do
  pod 'AFNetworking'


end

のような感じで、使用するライブラリのところにtargetが指定されていました。
これはライブラリを使用する対象のプロジェクト名を指定するようです。

これを参考にPodfileを修正してみました。
プロジェクト名はMyAppにしていますが、手元の環境にあわせてください。

platform :ios, '8.0'
target 'MyApp' do
    pod 'AFNetworking'
end

で、pod update します。

$ pod update
Update all pods
Re-creating CocoaPods due to major version update.
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (3.1.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total
pod installed.

成功しました!

おわりに

今日は誕生日なのですがちょうどブログ担当日ということで特に何もなかったのです。いつものように猫の写真を載せておきますね。
スマホをXperia X Performanceに変えたので、黒猫も写りが良くなった気がする。

週刊、ウチのネコ。第10号


この記事を書いた人

chao