- Ridvan Chasan
How to fix Error Failed to update CocoaPods repositories for iOS project (React Native on Mac OS)
On my MacBook Pro with Apple M1 Pro and macOS Monterey (12.4), I got the following error message when creating an React Native project.
Updating CocoaPods repositories (this may take a few minutes)
error Error: Failed to update CocoaPods repositories for iOS project.
Ckeck the Xcode Command Line Tools
Go to Preferences -> Locations and choose the Command Line Tools if the dropdown menu is empty.
Install CocoaPods via pod command fails
cd MyReactNativeProject cd ios pop install
cd MyReactNativeProject cd ios ios % pod repo update
The two commands also throw an error message.
LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle
[!] CocoaPods could not find compatible versions for pod "FlipperKit/FlipperKitUserDefaultsPlugin": In Podfile: FlipperKit/FlipperKitUserDefaultsPlugin (= 0.125.0) None of your spec sources contain a spec satisfying the dependency: `FlipperKit/FlipperKitUserDefaultsPlugin (= 0.125.0)`.
Searching for inspections failed: undefined method `map' for nil:NilClass
Initialization of the React Native project with a given architecture (arch -x86_64) also does not work
arch -x86_64 npx react-native init cd MyReactNativeProject
Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Delete the CocoaPods resositories and create the project
sudo rm -rf ~/.cocoapods/repos
npx react-native init cd MyReactNativeProject
cd ./cd MyReactNativeProject/ios && pod install
Pod installation complete! There are 55 dependencies from the Podfile and 46 total pods installed.