Can't install Cocoapods on M1 Silicon when setting up React Native environment

Viewed 666

I'm not able to install Cocoapods in context with setting up React Native environment on my M1 Silicon due to below error.

M1, 2020 MacOs Big Sur 11.3.1 X-Code 13.2.1

jonas@Air-von-Jonas ~ % sudo gem install cocoapods
Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
    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 ./siteconf20220424-55001-og2rl2.rb extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.

I already tried all of these, these, the official cocoapod guide and also tried the official React-Native hints.

1 Answers
  • In the first step, you must look for the terminal in the finder.
  • After this, you need to right-click on the terminal and then click on “get info”, and after this, you are required to check open using Rosetta, which you can easily find under the general menu.
  • After the above step, you should open the terminal, and then you need to type sudo gem install ffi
  • Then you are required to install the CocoaPods with the sudo gem install cocoapods
  • Once you have successfully installed the CocoaPods, you need to uncheck the box appearing on your screen with the Open using Rosetta, and it will again start working.
  • Then you can visit your project directory and work again.
Related