LoginSignup
6
0

More than 3 years have passed since last update.

Catalina10.15でCocoaPods1.10.0を入れる方法(Homebrew)

Posted at

はじめに

もともとgemでバージョン1.5.3を入れてたのですが、ライブラリアップデートに伴ってCocoaPods自体のバージョンも上げることになりsudo gem update cocoapodsを実行したら以下のエラーが発生

Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.

調べるとRubyのバージョン関係のエラーのようで、RubyのバージョンかインストールするCocoaPodsのバージョンを下げることで対応できるみたいなのですが、使用しているライブラリの関係上CocoaPods 1.10.0を入れる必要がありました。
これを機にgemからHomebrewでの管理に移行しようと思い、その際に行った作業を備忘録として投稿。

環境

macOS Catalina バージョン10.15.7
ruby2.6.3p62
CocoaPods 1.5.3

手順

既にインストールされてるCocoaPodsをアンインストールする

ターミナル
$ sudo gem uninstall cocoapods -n /usr/local/bin

Homebrewが既にインストールされてる場合はアップデートする
未インストールの場合はインストールする

ターミナル
$ brew update

HomebrewからCocoaPodsをインストールする

ターミナル
$ brew instal cocoapods

エラーが発生した場合

Error: The brew link step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/pod
Target /usr/local/bin/pod
already exists. You may want to remove it:
rm '/usr/local/bin/pod'

To force the link and overwrite all conflicting files:
brew link --overwrite cocoapods

To list all files that would be deleted:
brew link --overwrite --dry-run cocoapods

Possible conflicting files are:
/usr/local/bin/pod
/usr/local/bin/xcodeproj

上記のようなエラーは、gem installした時の痕跡が残っててシンボリックリンクが貼られなかったことが原因みたいです。
以下のコマンドを実行することで解決します。

ターミナル
$ brew link --overwrite cocoapods

おわりに

そもそもRubyのバージョンをどうにかすればgemのままインストールできたのでは...?
他にも「こうすればできるよ!」や「ここが間違ってるよ」など知見がある方がいましたら、コメントください。

参考記事

https://qiita.com/spring_i/items/181bc3c05142d1f80d93
https://github.com/CocoaPods/CocoaPods/issues/8955
https://teratail.com/questions/245100

6
0
1

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