If you found error message like this :
Error installing cocoapods: ERROR: Failed to build gem native extension
You should re-install
ruby
first before installcocoapods
.
$ brew reinstall ruby
Add the below to your path
$ export PATH="/usr/local/opt/ruby/bin:$PATH"
If needed add these flags.
$ export LDFLAGS="-L/usr/local/opt/ruby/lib"
$ export CPPFLAGS="-I/usr/local/opt/ruby/include"