If you found error message like this :
Error installing cocoapods: ERROR: Failed to build gem native extension
You should re-install
rubyfirst before installcocoapods.
$ brew reinstall rubyAdd 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"