がべーじこれくしょん

技術系とかいろいろ

pod installでコケてSwift開発やめかけた話

執筆・創作活動への支援をぜひお願いします🙏
Buy Me A Coffee

毎度おなじみ環境構築でコケるシリーズです。

今回はiOSアプリ開発で一躍話題となったCocoaPodsに関する話題です。

gemと同様に、CocoaPodsもPodfileというものを元にしてパッケージをインストールします。

そのときに使われるコマンドが、pod installなワケですが、

極稀に以下のようなエラーメッセージが出ることがあります。

[!] Unable to find a specification for `Alamofire`

かの有名なAlamofireが「ありません」というわけですから絶対におかしい

これの対処法については、以下の記事に載ってました。

qiita.com

試しにpod setupしてみます。

$ pod setup
~~~省略~~~
Please move or remove them before you merge.
  Aborting
  Updating 7063eec..cfe42c8
[!] CocoaPods was not able to update the `master` repo. If this is an unexpected issue and persists you can inspect it running `pod repo update --verbose`

コンフリクトしてる…??

とにかくかなり古いpodを使ってたみたいです。(化石…)

とりあえず指示通りpod repo update --verboseしてみます。

$ pod repo update --verbose
~~~省略~~~
  Please move or remove them before you merge.
  Aborting
  Updating 7063eec..e5f960c
[!] CocoaPods was not able to update the `master` repo. If this is an unexpected issue and persists you can inspect it running `pod repo update --verbose`

うーん治らない。

記事漁りしてたら近そうなissueが発掘されました。

CocoaPods was not able to update the `master` repo · Issue #5077 · CocoaPods/CocoaPods · GitHub

とりあえず提案に沿ってみる。

$ cd ~/.cocoapods/repos/master
$ git reset --hard
Checking out files: 100% (113726/113726), done.
HEAD is now at 7063eec [Add] TaskQueue 1.0.1
$ git status
On branch master
Your branch is behind 'origin/master' by 29491 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    Specs/0/
    Specs/1/
    Specs/2/
    Specs/3/
$ rm Specs/0/ Specs/1/ Specs/2/ Specs/3/

削除に長時間かかった。

では早速。

$ pod setup
CocoaPods 1.2.0 is available.
To update use: `sudo gem install cocoapods`

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

Setup completed
$ sudo gem install cocoapods

成功しました。こりゃ相当前にチャレンジして放置したんだなあ…(遠い目

なにはともあれこれでやっとこ開発環境整いました。思う存分AlamofireやらSwiftyJSONやらRealmやらを使えるわけで嬉しいです。

がんばるぞい