Problem installing Cocoapods on M1 mac

when i installing cocoapods . it shows error.

i tryed more different solution,
For exaple:

  1. Open terminal with Rosetta __ and write commad " sudo gem install ffi " __ ← it shows error as below .
Ignoring ffi-1.15.3 because its extensions are not built. Try: gem pristine ffi --version 1.15.3
Building native extensions. This could take a while...
ERROR:  Error installing ffi:
	ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20220203-5490-1b2r55p.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h

You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-21/2.6.0/ffi-1.15.5/gem_make.out
  1. i Run these lines. _ sudo arch -x86_64 gem install ffi & arch -x86_64 pod install _ it also shows same errors as above.

how to i installed cocoapods ?

From all reports that I have read, this is supposed to be the best method.

Download and install Homebrew using the following method:

Open terminal and paste in the following command string:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Now install cocoapods using the following command:

brew install cocoapods