I have some problem cocoapods installation

Goto Xcode preferences then click on Locations -> Command Line Tools -> Click on the drop down and check if any of it is available. If yes then select and set it. Then try to install cocoa pods it works as expected.

If no option is available in the drop down for Command Line Tools then use following commnands

xcode-select --install
sudo xcodebuild -license

Looks like you don't have installed Ruby development headers.

You can fix this by installing Xcode command-line tools by executing these two commands:

xcode-select --install
sudo xcodebuild -license

Changes will apply after the computer restart.