Cocoapods install and setup Cocoapods for Xcode

Hello boss.
i was trying getting cocoapods step by step fellowing your tutorial youtube video and it keeps showing errors which are
ERROR: Could not find a valid gem ‘cocoapds’ (>= 0) in any repository
ERROR: Possible alternatives: cocoapods, xcocoapods, cocoa, cocoa-xml, cocoadex

I don’t really know how to soluve that

thx

You already typed in wrong, as you typed in cocoapds according to your error, try doing it again ang make sure everything is typed and spelled correctly

hey but when I typed the code “sudo gem install cocoapods” it is showing the error
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
so plz tell me if I am wronger problem in my Mac

check the terminal if you are using bash or zhs, you should be using bash for this

also make sure you have and are running as administrator

thanks very much my freind

my terminal is running in zsh so can you tell me please what I have to do if I want to run it on bash and become administrator ?

To @fuerte.francis

when I am trying to install the cocoapods I am typing sudo gem install cocoapods in bash in terminal it is showing the error

ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.

please help me to how to solve this issue

When the installation fails can you copy and paste all of the diagnostics from the terminal in a reply. There may be other details listed that may be the key to identifying what the cause is.

can you check our cocoapods article if it can help? https://codewithchris.com/cocoapods/

is it really running zhs? , can you post a screenshot of your terminal as you open it?

when I firstly open the terminal it was running on zsh but now I have set it to bash

when I am typing sudo gem install cocoapods it is showing (the screenshot attached to this reply)Screenshot 2020-12-18 at 11.10.14 AM|690x431 )

@Siddharth

There is a stackoverflow thread that deals with an error related to ffi.

The thread suggests that you should perform the following installation in terminal:

sudo gem install ffi

@Chris_Parker

it is showing this

please tell me now what I have to do now ?

@Siddharth I have the same problem too… have you found any solution so far?

@happysoul

This thread may help.
https://codecrew.codewithchris.com/t/m1l3-firebase-cocoapods-install/10346/2

this page doesnot exists… can you please check and let me know the right guidance

The page does exist but obviously you can’t see it which means that you are not a CWC+ member given that the thread is within the CWC+ Students area.

This is the content of the thread:

You are not the first to have issues with cocoapods on an M1 chipped Mac with Big Sur. You and others are getting an error that points towards a missing ffi.c bundle as indicated by the first line in the error messages you posted above that says:

LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle, 0x0009): missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle - /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle

From what I have read the solution seems to be by firstly opening Terminal with Rosetta 2.

Here’s the workaround:

  • Locate the Terminal application within the Utilities folder (Finder > Go menu > Utilities)
  • Select Terminal.app and right-click on it, then choose “Duplicate”
  • Rename the duplicated Terminal app to something obvious and distinct, like ‘Rosetta Terminal’
  • Now select the freshly renamed ‘Rosetta Terminal’ app and right-click and choose “Get Info” (or hit Command+i)
  • Check the box for “Open using Rosetta”, then close the Get Info window
  • Now run sudo gem install cocoapods
    Reply with how things go.

Also, this article may be of assistance:

Hi
My MacBook Pro is with i9 however I followed the steps and I couldn’t see the option open using rosetta…
however below is the error message I am getting

[Restored 1 Mar 2021 at 15:28:59]
Last login: Mon Mar 1 15:19:17 on ttys000
bnmanikandan@Bns-MacBook-Pro ~ % sudo gem install cocoapods
Password:
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.14.2/ext/ffi_c

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20210301-13544-9vkdzc.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. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
–with-ffi_c-dir
–without-ffi_c-dir
–with-ffi_c-include
–without-ffi_c-include=${ffi_c-dir}/include
–with-ffi_c-lib
–without-ffi_c-lib=${ffi_c-dir}/lib
–enable-system-libffi
–disable-system-libffi
–with-libffi-config
–without-libffi-config
–with-pkg-config
–without-pkg-config
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in block in try_compile’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:534:in with_werror' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in try_compile’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1109:in block in have_header' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in block in checking_for’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in block (2 levels) in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in open’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in block in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in open’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in checking_for’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1108:in have_header' from extconf.rb:10:in system_libffi_usable?’
from extconf.rb:42:in `’

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.14.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.14.2/gem_make.out

If I run flutter doctor below is the error message:
bnmanikandan@Bns-MacBook-Pro ~ % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.27.0-9.0.pre.122, on Mac OS X 10.15.7 19H524 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[!] Xcode - develop for iOS and macOS
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side’s plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install see CocoaPods Guides - Getting Started for instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] Connected device (2 available)

! Doctor found issues in 1 category.