How to install cocoapods and pod

Hi, I am developing IOS(Android App) with React Native.

I am very confused about cocoapods and pod and how to correctly install it on my new Macbook Pro M4. I am not using bash but I am using zsh. Note, actuallywhich pod return nothing

During the preparation of my environment, it say

CocoaPods is one of the dependency management system available for iOS. CocoaPods is a Ruby gem. You can install CocoaPods using the version of Ruby that ships with the latest version of macOS.

the web site show two commands

gem install cocoapods
sudo gem install cocoapods

I saw another command as well

brew install cocoapods

During different processes, I experienced several time the following error (Command 'pod install failed)

Command pod install failed.

└─ Cause: pod install --repo-update --ansi exited with non-zero code: 1

Then I am confused about cocoapods and pod. Are both he same?

With my previous MacBook pro, I spend time to install cocoapod on my profile because Ruby was not the latest version on the system. But apparently, on my new Macbook Pro M4, the command ruby -v return (as well)

ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin25]

The current stable version is 4.0.0.

I bought a new macbook pro M4 and I reinstalled node and all package for Rect Native 0.81 a expo 54 excepted cocoapods. Now, I need to configure the push notification and it's time to install cocoapods as it's require here

But on my new macbook pro, I would like to make sure I do it correctly and I kindly ask your help and recommandation to install Ruby and cocoapods/pod

Q1: Should I install cocoapods with brew install cocoapods or gem install cocoapods? Q2: what's is the difference or the common point with cocoapods and pod?

Cocoapod web site said

If using the default Ruby included with macOS, installation will require you to use sudo when installing

gems

As ruby -v print 'ruby 2.6.10p210', I suppose, I should not install cocoapod with sudo

You can use a Ruby Version manager such as RVM or rbenv

to manage multiple Ruby versions, or you can use Homebrew to install a newer Ruby with brew install ruby.

As far I understand, I should not install cocoapods with the Ruby version of the system, then I suppose the command

Q3: Will 'brew install cocopads' install the latest version on my profile? Will it upgrade the system version Q4: What will do the command

brew install rbenv ruby-build
rbenv install 3.2.2 (or better: rbenv install 4.0.0)

in comparison with

brew install ruby

My guess I suppose that the following will help, but it would nice if you could correct me and clarify

# All should be done in my profile
brew install rbenv ruby-build
echo 'eval "$(rbenv init - bash)"' >> ~/.zprofile
source ~/.zprofile
rbenv install 4.0.0
# rbenv global 4.0.0 # What is it?
ruby -v
gem install cocoapods

Q5: But then, what about pod and the error message Command pod install failed.

As you can see, I am a bit confused and I would appreciate your clarification

I thanks you for your help and clarification and I wish you a happy new years

I guess, there is a error here and I corrected as the following

# All should be done in my profile
brew install rbenv ruby-build
echo 'eval "$(rbenv init - zsh)"' >> ~/.zprofile
source ~/.zprofile
rbenv install 4.0.0
# rbenv global 4.0.0 # What is it?
ruby -v
gem install cocoapods

By the way,

brew install cocoapods

Where cocoapods is installed? if I choose to install cocoapods with brew

I supposed the result is the same if I would install cocoapods with

gem install cocoapods
How to install cocoapods and pod
 
 
Q