LoginSignup
7
6

More than 5 years have passed since last update.

ld: library not found for -lPodsの対処法

Last updated at Posted at 2016-11-26

概要

MacBook Pro (15-inch, Late 2016)を買った。

自分が管理しているiOSアプリの開発環境を移行していたら、ビルドエラーが発生した。

ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)

開発環境

XCode 8.1
CocoaPods 1.1.1

原因

libPods.a 静的ライブラリーが見つからない。

どう対応したか。

とりあえず本家サイトを調べる。
本家のトラブルシューティングを確認すると、

If Xcode complains when linking, e.g. Library not found for -lPods, it doesn't detect the implicit dependencies:

Go to Product > Edit Scheme
Click on Build
Add the Pods static library, and make sure it's at the top of the list
Clean and build again
If that doesn't work, verify that the source for the spec you are trying to include has been pulled from GitHub. Do this by looking in <Project Dir>/Pods/<Name of spec you are trying to include>. If it is empty (it should not be), verify that the ~/.cocoapods/master/<spec>/<spec>.podspec has the correct git hub url in it.
If still doesn't work, check your Xcode build locations settings. Go to Preferences -> Locations -> Derived Data -> Advanced and set build location to "Relative to Workspace".

とあるので、その通りにやってみようとすると、
「Add Pods static library」
の部分で、Pods ライブラリが無い。無いので追加できない。

よく見てみると、Pods-ProjectNameのライブラリがある。

僕の場合は、同作業中にCocoaPodsのバージョンを1.x系にアップデートしていたので、
Podfileを書き直していた。

その過程でTargetを指定したので、
-lPods から -lPods-"Target"
に変更されていた。

そうすると、-lPodsの指定がいらないはず。

Project -> Build Phases -> Link Binary With Libraries
を確認すると、libPods.aが含まれていたので削除。

Clean して Build したらビルドできた。

記事書いてみて

普段は、あまり記事を書かないし、トラブルシューティング記事は特に書かないけど、
昨日職場でAdvent calendarの話が盛り上がったので書いてみた。
普段から各練習をしてないとやはり時間がかかるので、こまめに書くのもいいなと感じた。

この記事書くのに15分ぐらいかかった。

あとがき

すごい久しぶりにプロジェクトをビルドしたので、メンテナンス不足によるトラブルでした。
多分、世間が問題になった頃から大分経っていると思います。ウラシマ記事でした。

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