LoginSignup
7
5

More than 3 years have passed since last update.

pod installにハマった話

Posted at

背景

2015年の正月以来、iOSの開発から遠ざかってきましたが、
久しぶりにそういうお仕事をいただき、
環境構築しなきゃいけなくなったので、
その時のお話です。

当初の思っていたこと

  • 既存アプリをgitでクローンする
  • xCodeを起動して、シミュレータで動かす
    • エラーが出たらトライアンドエラーの繰り返し・・・A

「上記やればいいんでしょ」的な軽い気持ちに。

→で、このAに色々ハマったのでメモのため残します。

目的

cocoaPodsのインストール。ただこれだけ。

ハマったこと概要

  1. rbenvでrubyをインストールしようとしたら、エラーが全くでなくてすごいハマる
  2. opensslがbrewのに切り替わらなくてハマる
  3. cocoaPodsのsetupが終わらなくてハマる

0.序章:xCodeでのエラー

xCodeでビルドしたら
rojectName/Pods/Pods...ProjectName.debug.xcconfig unable to open file
というようなエラーが出ました。

プロジェクトでcocoaPodsを使っていたんですが、私のPCには入っていなかったのが原因。

https://stackoverflow.com/questions/55558984/xcode-pods-projectname-debug-xcconfig-unable-to-open-file-wrong-directory
を参考にして、

$ pod deintegrate
$ pod install

を完了させることで良いらしいことが判明。
これを解消することが目的だったんですが、色々とやりました。

1.rbenvのアップグレート

podインストールするために、gemが必要。
→gemを使うために、rubyをアップデートしないと。
→rbenv使っていたのでまずは最新にしないと。

と言う流れでした。

$ brew update
$ brew upgrade rbenv

これでOK。

2.rubyのアップグレード

結論から言うとこれに一番ハマりました。。。

$ rbenv install 2.5.0
ruby-build: use openssl from homebrew
Downloading ruby-2.5.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.0.tar.bz2
error: failed to download ruby-2.5.0.tar.bz2

BUILD FAILED (OS X 10.13.6 using ruby-build 20190423)
$

ログが少ない。。。
じゃあcurlを使ってやってみようかとなり(ここが一番ハマってた)実行。

$ curl -v -O https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.0.tar.bz2
* Hostname was NOT found in DNS cache
*   Trying 151.101.1.178...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to cache.ruby-lang.org (151.101.1.178) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
} [data not shown]
* SSLv3, TLS alert, Server hello (2):
{ [data not shown]
* error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
* Closing connection 0
curl: (35) error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
$

これかーーーー!!
opensslもcurlも何も最近してなかったから更新しようということに。

2-1.curlのアップデート

さてさて、curlはどこにあるんだろ?

$ which curl
/usr/local/php5/bin/curl
$ curl --version
curl 7.38.0 (x86_64-apple-darwin14.0.0) libcurl/7.38.0 OpenSSL/0.9.8zd zlib/1.2.11 libidn/1.20 libssh2/1.4.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp 
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz 

まさかphp5のを見に言っているとは。。。

・・・さ、気を取り直してupgradeしてパスの変更を

$ brew upgrade curl
$ brew link curl
$ sudo vi ~/.bash_profile 
$ source ~/.bash_profile
~/.bash_profile
## 以下を追加
export PATH="/usr/local/opt/curl/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/curl/lib"
export CPPFLAGS="-I/usr/local/opt/curl/include"
export PKG_CONFIG_PATH="/usr/local/opt/curl/lib/pkgconfig"

2-2.opensslのアップデート

さてさて、opensslはどこにあるんだろ?

$ which openssl
/usr/bin/openssl
$ openssl version
LibreSSL 2.2.7

これまたbrewのを見ていないので、これを機に変更しようと。
opensslのバージョンがLibreSSL 2.2.7なのが謎だけど今度調べよう。

・・・さ、気を取り直してupgradeしてパスの変更を

$ brew upgrade openssl
$ brew link openssl
$ sudo vi ~/.bash_profile 
$ source ~/.bash_profile
~/.bash_profile
## 以下を追加
export PATH="/usr/local/opt/openssl/bin:$PATH"

2.3 curlの再実行

さて、これでcurlうまく行くはず!

$ curl -v -O https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.0.tar.bz2
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 151.101.1.178:443...
* TCP_NODELAY set
* Connected to cache.ruby-lang.org (151.101.1.178) port 443 (#0)

・・・省略・・・

{ [2759 bytes data]
100 13.3M  100 13.3M    0     0  4815k      0  0:00:02  0:00:02 --:--:-- 4815k
* Connection #0 to host cache.ruby-lang.org left intact
$

という感じでうまくいったので、rubyをhttpsで取ってこれるハズ!

2.4 rubyインストールの再実行

結構時間かかりましたが無事に終了しました。

$ rbenv install 2.5.0 -v
ruby-build: use openssl from homebrew
/var/folders/cq/lhcj5t515fg5smk__8r_nwj00000gn/T/ruby-build.20190820113501.15161 ~/development/20190819
Downloading ruby-2.5.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.0.tar.bz2
/var/folders/cq/lhcj5t515fg5smk__8r_nwj00000gn/T/ruby-build.20190820113501.15161/ruby-2.5.0 /var/folders/cq/lhcj5t515fg5smk__8r_nwj00000gn/T/ruby-build.20190820113501.15161 ~/development/20190819
Installing ruby-2.5.0...

・・・省略・・・

Installed ruby-2.5.0 to /Users/hoge/.rbenv/versions/2.5.0
$

rubyのバージョンも変えて起きましょうね、と。

$ rbenv local 2.5.0
$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
$ which ruby
/Users/hoge/.rbenv/shims/ruby

3.gemのアップデート

しばらく使ってなかったのでアップデート。

$ sudo gem update --system
Password:
Updating rubygems-update
Fetching: rubygems-update-3.0.6.gem (100%)

・・・省略・・・

If you do not wish to install this documentation in the future, use the
--no-document flag, or set it as the default in your ~/.gemrc file. See
'gem help env' for details.

RubyGems system software updated
$

4.cocoaPodsのインストール

きました!今回の目的!!

$ sudo gem install cocoapods
Fetching concurrent-ruby-1.1.5.gem
Fetching thread_safe-0.3.6.gem

・・・省略・・・

Done installing documentation for thread_safe, tzinfo, concurrent-ruby, i18n, activesupport, nap, fuzzy_match, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, netrc, cocoapods-trunk, cocoapods-try, molinillo, atomos, CFPropertyList, colored2, nanaimo, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods after 22 seconds
28 gems installed
$ pod --version
1.7.5

順調順調。
さてあとは $ pod setupさえ実行できちゃえばと思い実行・・・したんですが、終わらない。。。

そしたら他の方もハマっているようで、参考にさせていただきました。
https://qiita.com/pei0804/items/be16a07db87c21703693

4.1 pod setupの短縮化

上記を参考にさせていただき、以下を実行しました。

$ cd ~/.cocoapods/repos
$ rm -rf master
$ git config --global http.postBuffer 524288000
$ git clone https://github.com/CocoaPods/Specs.git master
$ pod setup

5.pod install の実行

$ pod deintegrate
$ pod install

これで全て終了。
iOSアプリもビルドが通り、無事に立ち上がりました。

7
5
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
7
5