N Kaushik

Fix for Failed to install CocoaPods dependencies for iOS project, which is required by this template

December 07, 2021

Fix for Failed to install CocoaPods dependencies for iOS project, which is required by this template:

I faced this issue while initializing a new react-native project. You might face this issue if you are starting a new react-native project or if you are working on an existing project.

This error says that it fails to install the dependencies for the iOS project. If your project is only for Android, you can ignore this error. It will run without any issue on Android. But, only for iOS, you need to use cocoapods to install few dependencies before you run it.

Full error:

Below is the complete error:

✖ Installing CocoaPods dependencies (this may take a few minutes)
✖ Installing CocoaPods dependencies (this may take a few minutes)
error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./TestReactNative/ios && pod install".
CocoaPods documentation: https://cocoapods.org/
$ cd TestReactNative/ios 
$ pod install
Ignoring ffi-1.14.2 because its extensions are not built. Try: gem pristine ffi --version 1.14.2
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`
Fetching podspec for `boost` from `../node_modules/react-native/third-party-podspecs/boost.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`

――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

Command

/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod install

Report

  • What did you do?

  • What did you expect to happen?

  • What happened instead?

Stack

   CocoaPods : 1.10.1
        Ruby : ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]
    RubyGems : 3.0.3.1
        Host : macOS 12.0.1 (21A559)
       Xcode : 13.0 (13A233)
         Git : git version 2.30.1
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : 

Plugins

cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-trunk       : 1.5.0
cocoapods-try         : 1.2.0

Podfile

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'

target 'TestReactNative' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  target 'TestReactNativeTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

Error

LoadError - dlsym(0x201548fa0, Init_ffi_c): symbol not found - /opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/ffi-1.14.2/lib/ffi_c.bundle
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/ffi-1.14.2/lib/ffi.rb:6:in `rescue in <top (required)>'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/ffi-1.14.2/lib/ffi.rb:3:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/ethon-0.12.0/lib/ethon.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:74:in `cdn_url?'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:36:in `create_source_with_url'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:21:in `find_or_create_source_with_url'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:178:in `block in sources'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:177:in `map'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:177:in `sources'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1073:in `block in resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:414:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:160:in `install!'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod:23:in `load'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod:23:in `<main>'

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

[!] Oh no, an error occurred.

Cocoapods install fail error

The failure is on installing the iOS dependencies using cocoapods. You can follow the following steps to fix this.

Go to the iOS folder and do pod install:

Move to the iOS folder inside the react native project in your terminal and run pod install to install the pods. If you see the same errors again, you can move to the next step.

Update cocoapods:

Update cocoapods:

breaw install cocoapods

brew upgrade:

Upgrade the dependecies by using the following command:

brew upgrade

And do a cleanup:

brew cleanup

If you don’t want to upgrade all brew packages, you can also mention the package name:

brew upgrade package_name

Once you are done, you can try pod install again inside the iOS folder. It should fix it. You will see something like below once pod install is done:

Pod install success

If you love this article, please do subscribe to my newsletter for more similar content.


Subscribe to my Newsletter