Problem installing Cocoapods on older iMac running macOS 12.7.3

152 views Asked by At

I'm a bit of a newbie, so please bear with me. :|

                                 ***************
  1. I'm trying to add a pod to a Swift app I'm building in Xcode.

  2. When I tried to install Cocoapods it threw a bunch of errors (see below).

                                  ***************
    

$ sudo gem install cocoapods

Fetching ruby-macho-2.5.1.gem Fetching escape-0.0.4.gem Fetching nap-1.1.0.gem Fetching fourflusher-2.3.1.gem Fetching colored2-3.1.2.gem Fetching addressable-2.8.6.gem Fetching gh_inspector-1.1.3.gem Fetching public_suffix-4.0.7.gem Fetching rexml-3.2.6.gem Fetching nanaimo-0.3.0.gem Fetching claide-1.1.0.gem Fetching atomos-0.1.3.gem Fetching xcodeproj-1.24.0.gem Fetching molinillo-0.8.0.gem Fetching cocoapods-try-1.2.0.gem Fetching netrc-0.11.0.gem Fetching cocoapods-trunk-1.6.0.gem Fetching cocoapods-search-1.0.1.gem Fetching cocoapods-plugins-1.0.0.gem Fetching cocoapods-downloader-2.1.gem Fetching cocoapods-deintegrate-1.0.5.gem Fetching ffi-1.16.3.gem Fetching ethon-0.16.0.gem Fetching typhoeus-1.4.1.gem Fetching concurrent-ruby-1.2.3.gem Fetching httpclient-2.8.3.gem Fetching algoliasearch-1.27.5.gem Fetching fuzzy_match-2.0.4.gem Fetching ruby2_keywords-0.0.5.gem Fetching drb-2.2.0.gem Fetching base64-0.2.0.gem Fetching connection_pool-2.4.1.gem Fetching tzinfo-2.0.6.gem Fetching i18n-1.14.1.gem Fetching activesupport-7.1.3.gem Fetching cocoapods-core-1.15.0.gem Fetching cocoapods-1.15.0.gem Successfully installed public_suffix-4.0.7 Successfully installed addressable-2.8.6 Successfully installed ruby-macho-2.5.1 Successfully installed nap-1.1.0 Successfully installed gh_inspector-1.1.3 Successfully installed fourflusher-2.3.1 Successfully installed escape-0.0.4 Successfully installed colored2-3.1.2 Successfully installed rexml-3.2.6 Successfully installed nanaimo-0.3.0 Successfully installed claide-1.1.0 Successfully installed atomos-0.1.3 Successfully installed xcodeproj-1.24.0 Successfully installed molinillo-0.8.0 Successfully installed cocoapods-try-1.2.0 Successfully installed netrc-0.11.0 Successfully installed cocoapods-trunk-1.6.0 Successfully installed cocoapods-search-1.0.1 Successfully installed cocoapods-plugins-1.0.0 Successfully installed cocoapods-downloader-2.1 Successfully installed cocoapods-deintegrate-1.0.5 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.16.3/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 ./siteconf20240202-1849-nov6jr.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-debug --disable-debug --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:46: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-21/2.6.0/ffi-1.16.3/mkmf.log

extconf failed, exit code 1

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

                                 ***************
  1. Usually this happens because I'm running a fairly old macOS version (my iMac is so old it can no longer update beyond macOS 12) so I just install older versions of software. But as I'm a bit new to code, I don't really know how to fix this one.

  2. It looks like I'm running Ruby 2.6.0, which is too old to upgrade to the latest version of Ruby.

  3. I tried to upgrade Ruby gems (see below) per instructions I found somewhere but can't find again (I trawled through loads of threads but everything else looked far too advanced for my current level).

  4. I reckon the latest version of Cocoapods is incompatible with Ruby 2.6.0 so I need to either find and install an older version of Cocoapods, or somehow upgrade my Ruby.

  5. I'd prefer to avoid adding a huge amount of workarounds, codes, plugins, etc. to an already declining iMac if possible.

  6. Please please help this wannabe coder with your simplest and old-iMac-friendliest suggestions. Thank you.

                                  ***************
    

$ sudo gem update --system

Updating rubygems-update Fetching rubygems-update-3.5.5.gem ERROR: Error installing rubygems-update: There are no versions of rubygems-update (= 3.5.5) compatible with your Ruby & RubyGems rubygems-update requires Ruby version >= 3.0.0. The current ruby version is 2.6.10.210. ERROR: While executing gem ... (NoMethodError) undefined method `version' for nil:NilClass

                                 ***************
1

There are 1 answers

1
Laura On

Okay, so here's an answer / update / new cry for help...

After the advice, "Try with homebrew?" I found this question/answer: Unable to install Cocoapods in macOS Monterey Version 12.0 Beta - Xcode 13.0(13A233)

Which basically suggests the solution is to simply enter: $ homebrew install cocoapods

So I tried that. And it kinda worked. So... partial answer received I guess (and therefore posted here for other Monterey users to find more easily).

However...

I now need help with the next problem:

                           ************

Error: The brew link step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink bin/xcodeproj Target /usr/local/bin/xcodeproj already exists. You may want to remove it: rm '/usr/local/bin/xcodeproj'

To force the link and overwrite all conflicting files: brew link --overwrite cocoapods

To list all files that would be deleted: brew link --overwrite --dry-run cocoapods

Possible conflicting files are: /usr/local/bin/xcodeproj ==> Summary /usr/local/Cellar/cocoapods/1.15.0: 13,736 files, 28.8MB ==> Running brew cleanup cocoapods... Pruned 12 symbolic links and 8 directories from /usr/local

                           ************