LoginSignup
108
99

More than 5 years have passed since last update.

Xcode+CocoaPodsで起こった問題と対処

Last updated at Posted at 2015-05-07

CocoaPodsで発生したエラーに諸々対処。

pod updateでエラー

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:245:in `mkdir': Permission denied - /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14 (Errno::EACCES)
...

他にも諸々エラーが発生しました。
とりあえずこれに関してはまずgemのアップデートからしろってことで普通に

$sudo gem update

アップデートが完了したあとで、

$pod update

アップデート後にエラー

[!] Unable to load a specification for the plugin /Library/Ruby/Gems/2.0.0/gems/cocoapods-try-release-fix-0.1.2

以下のURLを参考に、削除
https://github.com/CocoaPods/CocoaPods/issues/2641

$ [sudo] gem uninstall cocoapods-try-release-fix

Podfile.lock No such file or directory

diff: /../Podfile.lock: No such file or directory
diff: Manifest.lock: No such file or directory error:
The sandbox is not in sync with the Podfile.lock. Run ‘pod install’ or update your CocoaPods installation.`

pod installしたのに、なぜかこんなことを言われてビルドエラーに。
以下のURLを参考に、User-Definedを追加しました。

◆ Podインストールしたのに「diff: /../Podfile.lock: No such file or directory」のエラーが出現した際の対処法
http://www.ateliee.com/archives/2364

  1. プロジェクトのBuild-SettingsにUser-Definedがなければ、追加
    スクリーンショット 2015-05-07 11.58.11.png
     

  2. 名前をPODS_ROOT、値を${SRCROOT}/Podsに設定
    スクリーンショット 2015-05-07 13.09.35.png
     

  3. pod installのやり直し(.xcworkspace、Podfile.lock、Podsの削除)

header file が file not foundになる

'SDWebImage/UIImageView+WebCache.h' file not found
'AFNetworking/AFHTTPRequestOperation.h' file not found

今度はヘッダファイルがfile not foundに…。
なんかこんな感じで、これまで通っていた下記のようなimportでエラーが発生してきました。
#import <UIImageView+WebCache.h>

header search pathに定義を追加したり色々しましたが全てダメでしたが、
結果として以下のURLを参考にTargetを編集したら直りました。

◆ Cocoapods can't find header xcode 6
http://stackoverflow.com/questions/26095775/cocoapods-cant-find-header-xcode-6

ProjectのInfoタブから、ConfigurationsでNoneになっている箇所を修正します。
ss.png

とりあえず私の環境では、ここまでを行った時点で正常にビルドが通るようになりました。

と思ったら、また実機インストールで動かなくなった…ので、対処方法追加

Linkerエラー

clang: error: linker command failed with exit code 1 (use -v to see invocation)

-lPodsやら、-lAFNetworkingやらがLinkerエラーを起こしました…。
とりあえず、PodsのProjectも含めて「Build Settings->Architectures/Build Active Architecture Only」がYESになっていたら、NOに変更しましょう。

5/29追記
それでもlinker errorになることがあったので。
「Build Settings->Other Linker Flags」を確認して、「$(inherited)」が設定されていなかったら追加しましょう。

※ちなみに、これはPROJECTに対して追加しても意味がありません。
各TARGETのOther Linker Flagsに対して追加してください。

2017/08/23追記
古いプロジェクトで、何をやってもLinker Errorが取れなかったので調べたところ、以下が参考になった。
https://github.com/CocoaPods/CocoaPods/issues/5779

記事内の解決方法とは少し違うが、Podsの0.*.*からメジャーバージョンにアップデートした場合にLinked Frameworks and Librariesに古いPods.aファイルが残っていることがある。
これが残ったままだとLinker Errorが取れない。

Shell Script invocation error

Run custom shell script 'Copy Pods Resources' で変なエラーが。

line 2: /xxx/Pods/Pods-resources.sh: No such file or directory

とかよく分からないことを言っています。
諸々調べたがよく分からないので、とりあえずPods-resources.shを探してみたら
最新のcocoapodsでインストールした環境には存在しない……?

スクリーンショット 2015-05-07 15.58.35.png

と思ったら、これはどうも記述が古くて最新のPodsではScriptの内容が
更新されているようでした。
そこで、記述を以下のように更新すれば通るようになります。

"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh"

108
99
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
108
99