LoginSignup
30
25

More than 5 years have passed since last update.

Cocoapods の pod install で色々はまった時の解消法メモ

Posted at

Cocoapodsを使って依存ライブラリをインストールした時に色々ハマったので解消方法をメモ。

環境

  • Cocoapods version 1.0.1

The dependency xxxx is not used in any concrete target.

以下のようなPodfileを作成し、pod installコマンドを実行したらエラーが。

pod 'AWSAPIGateway', '~> 2.2.1'
$pod install
[!] The dependency `AWSAPIGateway (~> 2.2.1)` is not used in any concrete target.

メッセージを読むと targetが指定されていないと書いているようにみえるが。。

調べてみると以下の記事が。

Cocoapods 1.0.0で注意すること

Cocoapods 1.0.0から podfile でターゲットを指定しないといけないようです。
pod initコマンドで対象のプロジェクトのPodfileのテンプレを作成し、それに追記するのが良さそう。

$pod init
$cat Podfile
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

target 'HelloWorld' do
  # Uncomment this line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for HelloWorld

  target 'HelloWorldTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'HelloWorldUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

あとは上記を変更すればOKです。

pod repo updateが失敗する

解消したと思ったら次のようなエラーが。

$pod install
Analyzing dependencies
[!] Unable to satisfy the following requirements:

- `AWSAPIGateway (~> 2.4.7)` required by `Podfile`

None of your spec sources contain a spec satisfying the dependency: `AWSAPIGateway (~> 2.4.7)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.

pod install した時に pod repo updateコマンドを実行しないよというメッセージが。
じゃあと実行してみました。

$pod repo update

Please commit your changes or stash them before you can merge.
error: The following untracked working tree files would be removed by merge:
      Specs/ALSPopView/1.0.1/ALSPopView.podspec.json
      Specs/ALSPopView/1.0.2/ALSPopView.podspec.json
      Specs/ALSPopView/1.0/ALSPopView.podspec.json
      Specs/AdMobMediationAdapterFB/1.2.1.1/AdMobMediationAdapterFB.podspec.js

--versbose オプションを付けて実行する分かるのですが、内部的にはgit pullを実行しているようで恐らくgit pull しているレポジトリの所でcommitされていないファイルなどがあるようでエラーになっているような。

調べてみると以下のGithub の issueが。

pod install git conflict

git reset HEAD --hardで一旦HEADに戻せば大丈夫とのことでやってみます。

$cd ~/.cocoapods/repos/master/
$git reset HEAD --hard

再度実行してみます。

$pod repo update

・・・

CocoaPods 1.1.0.rc.2 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.1.0.rc.2

成功。
CococPodsの1.1.0rc2があるよと言われるがtest versionらしいのでやめときます。。。

問題解消後、pod installで依存ライブラリがインストールできました。
良かったー。

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