LoginSignup
2
1

More than 3 years have passed since last update.

Ruby3.0.0 で CocoaPods install / update に失敗する問題の解決策

Last updated at Posted at 2021-01-30

はじめに

Ruby: 3.0.0
CocoaPods: 1.10.1
macOS: 11.1
Xcode: 12.3

現象: Generating Pods project に失敗する

まず、このような現象は様々な原因が考えられます。エラー文言や挙動確認を行い、自分が直面している問題の原因を探りましょう。この記事がその分析の助けになれば幸いです。

結論だけ知りたい人は

Ruby 3.0.0 以降の方は gem 'rexml' を Gemfile に追加することで解決するかもしれません。

症状

$ bundle exec pod update --repo-update
Update all pods
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
...
Generating Pods project

――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
...
### Error

LoadError - cannot load such file -- rexml/document
/Users/akkeylab/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/xcodeproj-1.19.0/lib/xcodeproj/scheme.rb:1:in `require'
/Users/akkeylab/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/xcodeproj-1.19.0/lib/xcodeproj/scheme.rb:1:in `<top (required)>'
/Users/akkeylab/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/xcodeproj-1.19.0/lib/xcodeproj/project.rb:840:in `require'
/Users/akkeylab/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/xcodeproj-1.19.0/lib/xcodeproj/project.rb:840:in `recreate_user_schemes'
...

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=cannot+load+such+file+--+rexml%2Fdocument&type=Issues

If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods...
 - LoadError - cannot load such file -- rexml/document
   https://github.com/CocoaPods/CocoaPods/issues/10388 [open] [2 comments]
   41 minutes ago

 - Crash when reading Xcode project during intergration
   https://github.com/CocoaPods/CocoaPods/issues/2483 [closed] [76 comments]
   30 Mar 2015
  1. Generating Pods project でコケていることが分かる
  2. Ruby 側のエラーは LoadError - cannot load such file -- rexml/document
  3. 同様のエラーに関する issue が立てられている(https://github.com/CocoaPods/CocoaPods/issues/10388)

ざっくり分かることは以上です。

分析と解決策

  1. Ruby と CocoaPods でミスマッチなバージョンがインストールされていないか確認
  2. Gemfile で管理している場合は正しい Ruby, CocoaPods が呼び出されているか確認
  3. ライブラリの依存関係を疑ってインストールするライブラリを1つだけもしくはゼロにする。これでも Generating Pods project に失敗するようであればインストールするライブラリ側に問題がある可能性は低い
  4. CocoaPods をツール系も含めて全て再インストール&キャッシュ( ~/.cocoapods)削除
  5. 新規プロジェクトを作成して pod init してみる。失敗すればプロジェクトファイルに関連する問題は除外される
  6. 複数 Xcode がインストールされている場合、正しいバージョンにスイッチされているか、正しいデベロッパツールはインストールされているかの確認(Carthage の場合はここの優先度が高い)

本当に行き詰まったときは以上のような確認手順があるかと思います。
ただ今回は、かなり親切にヒントがログとして出力されているのでそちらを見ていきます。

LoadError - cannot load such file -- rexml/document

rexml/document がロードできなかったと仰っております。
Rails 6.1: What is preventing tests from running?
これをキーに調べてみると上記の記事にたどり着きました。
ざっくりと回答をまとめると「rexml という gem は Ruby 3.0.0 以降明示的にインストールする必要があります」とのことです。ということで、解決策としては以下の項目を Gemfile に追加、もしくは gem install するということになります。

gem 'rexml'

おわりに

今回の問題は Ruby 側に目を向けてあげる必要があるものでした。問題解決に苦戦したときは少し視野を広げてみると良いかもしれませんね!

2
1
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
2
1