SolvedCocoaPods Current CocoaPods should be installable on Mojave without dependency upgrades

Several tickets related to this problem have been closed as having to do with the user's build environment rather than the CocoaPods install itself (here's one closed yesterday). That would be reasonable if this was an extremely old OS or the user had messed it up, but we're talking about a perfectly normal Mojave install. Mojave is only one major version behind.

CocoaPods installation should not fail on an unmodified Mojave installation. Please reconsider the "not our problem" attitude. CocoaPods should be usable without difficulty on all macOS platforms that are in wide usage. Leaving high barriers for users unaddressed is bad for CocoaPods. I beg you to consider at least one of the following options:

  • If possible, revert the Ruby dependencies that created this problem.
  • If possible, change the gem installation to output a helpful response with instructions when this failure occurs (I don't know if the output from gem install can be controlled).
  • At an absolute minimum, please add a prominent notice to the installation instructions on the website indicating that the installation may not work on Mojave and how to fix it (e.g., install rvm and Ruby 2.6.x).

From the perspective I'm coming from, the current approach appears as a rather shocking disregard for CocoaPods's usability. I really beg you to think again about addressing this problem. It's clearly common, and it will only be to CocoaPods's benefit to give users an assist here.


What did you do?

sudo gem install cocoapods on macOS Mojave 10.14.6

What did you expect to happen?

Expected CocoaPods to install cleanly.

What happened instead?

Ruby errors: "Failed to build gem native extension." To resolve the problem I had to search through CocoaPods issues and StackOverflow and try to evaluate a number of different suggestions for solving the problem, most of which were not solidly within my current expertise (I haven't worked in Ruby for several years). Ultimately I installed rvm and Ruby 2.6.3, and that worked, but from the available sources, I didn't have great confidence that it was the best solution.

CocoaPods Environment


29 Answers

โœ”๏ธAccepted Answer

Here's an annotated transcript of my console session reproducing the problem.

I've also discovered that even though I've now built CocoaPods correctly, I can't run it. I've just begun to look at that, but it looks like it's still using a search path that includes the system Ruby. That's at the end of this transcript.

Initial environment โ€” note using system Ruby, v2.3.7:

[1 12:49 ~/] where ruby

[2 12:49 ~/] which ruby

[3 12:49 ~/] ruby --version
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]

For good measure, although I don't think this is important:

[4 12:49 ~/] xcode-select -p

[5 12:49 ~/] xcode-select -v
xcode-select version 2354.

Initial attempt to install Cocoapods fails due to missing header files:

[6 12:50 ~/] 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.3.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20200324-65620-13stqp2.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

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

Install rvm and use it to install Ruby 2.6.x (as suggested on StackOverflow):

[7 12:50 ~/] curl -sSL | bash
Installing RVM to /Users/matthias/.rvm/
    RVM PATH line found in /Users/matthias/.mkshrc /Users/matthias/.profile /Users/matthias/.bashrc /Users/matthias/.zshenv.
    RVM sourcing line found in /Users/matthias/.profile /Users/matthias/.bash_profile /Users/matthias/.zlogin.
Installation of RVM in /Users/matthias/.rvm/ is almost complete:

  * To start using RVM you need to run `source /Users/matthias/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM ๐Ÿ™
Please consider donating to our open collective to help us maintain RVM.

๐Ÿ‘‰  Donate:

[8 12:52 ~/] which rvm

[10 12:52 ~/] . ~/.rvm/scripts/rvm
. ~/.rvm/scripts/rvm

[11 12:52 ~/] echo $PATH

[12 12:52 ~/] rvm install 2.6
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.14/x86_64/ruby-2.6.5.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/matthias/.rvm/rubies/ruby-2.6.5, this may take a while depending on your cpu(s)...
ruby-2.6.5 - #downloading ruby-2.6.5, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.4M  100 13.4M    0     0  4498k      0  0:00:03  0:00:03 --:--:-- 4499k
ruby-2.6.5 - #extracting ruby-2.6.5 to /Users/matthias/.rvm/src/ruby-2.6.5 - please wait
ruby-2.6.5 - #configuring - please wait
ruby-2.6.5 - #post-configuration - please wait
ruby-2.6.5 - #compiling - please wait
ruby-2.6.5 - #installing - please wait
ruby-2.6.5 - #making binaries executable - please wait
ruby-2.6.5 - #downloading rubygems-3.0.8
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  867k  100  867k    0     0  1779k      0 --:--:-- --:--:-- --:--:-- 1777k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.6.5 - #extracting rubygems-3.0.8 - please wait
ruby-2.6.5 - #removing old rubygems - please wait
ruby-2.6.5 - #installing rubygems-3.0.8 - please wait
ruby-2.6.5 - #gemset created /Users/matthias/.rvm/gems/ruby-2.6.5@global
ruby-2.6.5 - #importing gemset /Users/matthias/.rvm/gemsets/global.gems - please wait
ruby-2.6.5 - #generating global wrappers - please wait
ruby-2.6.5 - #gemset created /Users/matthias/.rvm/gems/ruby-2.6.5
ruby-2.6.5 - #importing gemsetfile /Users/matthias/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.6.5 - #generating default wrappers - please wait
ruby-2.6.5 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.5 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri

[13 12:56 ~/] rvm use ruby-2.6.5
Using /Users/matthias/.rvm/gems/ruby-2.6.5

Confirm using Ruby 2.6.5:

[14 12:57 ~/] where ruby

[15 12:57 ~/] which ruby

CocoaPods installation is now successful:

[16 12:57 ~/] sudo gem install cocoapods
Fetching tzinfo-1.2.6.gem
Fetching concurrent-ruby-1.1.6.gem
Fetching ffi-1.12.2.gem
33 gems installed

Running pod still fails: [UPDATE: this piece is fixed]

[24 01:05 ~/] pod
Ignoring executable-hooks-1.6.0 because its extensions are not built.  Try: gem pristine executable-hooks --version 1.6.0
Ignoring ffi-1.12.2 because its extensions are not built.  Try: gem pristine ffi --version 1.12.2
Ignoring gem-wrappers-1.4.0 because its extensions are not built.  Try: gem pristine gem-wrappers --version 1.4.0
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': incompatible library version - /Users/matthias/.rvm/gems/ruby-2.6.5@global/gems/ffi-1.12.2/lib/ffi_c.bundle (LoadError)
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Users/matthias/.rvm/gems/ruby-2.6.5@global/gems/ffi-1.12.2/lib/ffi.rb:6:in `rescue in <top (required)>'
	from /Users/matthias/.rvm/gems/ruby-2.6.5@global/gems/ffi-1.12.2/lib/ffi.rb:3:in `<top (required)>'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

Other Answers:

It turns out the app is actually pretty out of date, so I did the following to get cocoa pods to work

  1. brew install cocoapods
  2. At this point pod install was failing, and I had to do rvm use system (I'd previously installed a few different versions to try and fix things up above). After this everything worked without issue.

Related Issues:

CocoaPods [error report] pod install /w m1 macbook
do you have a MacBook Pro with a M1 processor? this fixed my issue: Report What did you do? Run pod ...
CocoaPods NoMethodError - undefined method `size' for nil:NilClass
Also faced with this issue Fixed by updating flutter and cocoa pods to the latest version and then ...
CocoaPods pod install has bug
Did you try: sudo arch -x86_64 gem install ffi And run: arch -x86_64 pod install instead of pod inst...
CocoaPods CocoaPods was not able to update the master repo
Looks like your specs repo was edited at some point and now git can't update it ...
CocoaPods CocoaPods compatibility with Apple DTK (Apple Silicon)
For anyone else struggling with this issue I just found a way to solve it In addition to running ter...
CocoaPods Build issue with Xcode 12.3 - file not found #include "ruby/config.h"
I just updated to Xcode 12.3 and I am hitting this issue Seems like Xcode 12.3 broke the system ruby...
CocoaPods Unzip fail when zip contains chinese char on macOS 10.13
Maybe replace unzip with ditto: I have a SDK and there is a folder named FaceDistortion_20171205้›ชๅคฉ็š„้›ช...
CocoaPods None of your spec sources contain a spec satisfying the dependencies
Did you note this part of the error message: Note: as of CocoaPods 1.0 pod repo update does not happ...
CocoaPods pod install fails with json error on Mac OS X 10.15
I did rm -rf ~/.cocoapods/repos/trunk/ After that it worked again. I've read and understood the CONT...
CocoaPods No such file or directory @ rb_sysopen -- AppCenter -- ReactNative
So I updated my appcenter dependencies from v2.4.0 to v2.5.0 and I'm having this issue again ๐Ÿ™„ Edit...
CocoaPods App Icons not included in build from Xcode 9
I have the same problem Report What did you do? Run project on device from Xcode 9 Beta 6 What did y...
CocoaPods Intermittent CDN issues
The workaround to get working locally during this outage or CDN issue - guessing a DNS change or som...
CocoaPods new Macbook M1 crash
As a temporary fix I've installed cocoapods using sudo arch -arch x86_64 gem install cocoapods then ...
CocoaPods Support multiple Swift versions on a per pod basis
this works: It's not pretty but will do until they update your pods to Swift 4. ...
CocoaPods pod update error with CDN
And? How to fix? gem install concurrent-ruby or gem update concurrent-ruby. I've read and understood...
CocoaPods Failed to build gem native extension. Header file missing,
I had the same problem on macOS Mojave 10.14.16 A few threads eventually lead me here which solved i...
CocoaPods I can not install pod files.
Nope Just do: Install ffi sudo arch -x86_64 gem install ffi Re-install dependencies arch -x86_64 pod...
CocoaPods CocoaPods1.9.0 cannot install on Mojave10.14.6
This should be re-opened I can repro on a clean Mojave The workaround is to run sudo gem install coc...
CocoaPods [Xcode 8 beta 2]: CopySwiftLibs for Pods framework fails with Mach-O header error
I've found a workaround Add the following lines to your Podfile: ๐ŸŒˆ I've read and understood the *CO...
CocoaPods FBSDKLoginKit can not find headers under 1.0.0
This appears to be some issue between CocoaPods and XCode I tried to reproduce the problem I was see...
CocoaPods Podfile without use_frameworks! triggers "deployment target" warnings in Xcode 10
For those wanting a quick fix: edit: updated snippet now supports the new generate_multiple_pod_proj...
CocoaPods Resources installed using cocoapods not loaded for xctest bundle
For me I fixed it by setting Host Application to main target (In Test Target -> `General) ...
CocoaPods CDN: trunk Repo update failed - 2 error(s):
pod repo list ๆŸฅ็œ‹ๆบๅˆ—่กจ pod repo remove trunk ็งป้™คtrunkๆบ ๅชๆœ‰็งป้™คๆŽ‰้—ฎ้ข˜ๆ‰่งฃๅ†ณ๏ผ๏ผ๏ผ 2019.11.07ๆ›ด ๆ€•ๆœ‰ไบบไธๆ‡‚๏ผŒ็‰นๆ„ๅ†™ไบ†ไธ€็ฏ‡ๆ–‡็ซ  ๅ…ทไฝ“ๆ“ไฝœ็œ‹ไธ‹่ฟ™็ฏ‡...
CocoaPods [1.9.2] Error during pod install JSON::ParserError - 767: unexpected token
Running only sudo rm -rf ~/.cocoapods/repos and then pod install was enough for my case. ...
CocoaPods pod lib create fails: uninitialized constant Nanaimo::Reader::StringScanner (NameError)
gem uninstall nanaimo It will prompt you for which version to uninstall ๐Ÿ‘ Before you start ...
CocoaPods pod install triggers pods to use Swift 4.2 in XCode 10
I was also facing the same problem and able to fix by adding swift_version in pre_install block Is t...
CocoaPods pod spec lint fails (Xcode 8 GM & Cocoapods 1.1.0.rc.1)
Got it working using the .swift-version file mentioned in #5841 For those who need help make a .swif...
CocoaPods undefined method `map' for nil:NilClass (NoMethodError) Did you mean? tap
ah gem update xcodeproj fixes the problem for me I've read and understood the CONTRIBUTING guideline...
CocoaPods error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
This seems like an issue with cloning the master repo Could be an issue with your connection or the ...
CocoaPods Malformed version number string
if your rubyGems version is 2.7.7 or higher you just can do like this gem update --system 2.7.6 my p...
CocoaPods Pod with swift 4.2 fails at linting
The podspec contains s.source_files = Constrictor/Constrictor/**/* which includes all files includin...
CocoaPods LoadError - cannot load such file -- macho
TBH I'm not familiar with ruby so this may be a terrible solution I tried with versions 1.5.0 and 1....
CocoaPods Modules not found in test targets
Thanks for the great ticket! So pods would be passed to a target by inheritance here but you're not ...
CocoaPods Duplicate symbols when framework target has a static dependency
I have a new version of the workaround It works when some static libraries are only used in the Appl...
CocoaPods UITests missing ๐Ÿ“ฆ Embed Pods Frameworks build phase in 1.0.0.rc.1
Moving the UITests target outside of the main target in the Podfile seems to have helped So now inst...
CocoaPods Fails to install cocoapods on Ruby 2.4
Luckily cocoapods v1.0.1 still works Reproduction Detail CocoaPods has dependency in activesupport g...
CocoaPods Unit tests do not run on iOS 11 devices on Xcode 11 when using dynamically linked libraries
@dvataksi16 I got a response from Apple with a non-hacky solution: After reviewing your feedback we ...
CocoaPods ๐Ÿ› : Unable to install pods using custom build configurations
Just to leave a clear solution here Thankfully the solution is already merged to RN 0.63.3 ...
CocoaPods pod install: [!] Oh no, an error occurred.
This was what worked for me - arch -x86_64 pod install Report [!] Oh no an error occurred ...
CocoaPods Raise default macOS/iOS deployment target
The same is happening with iOS btw I've read and understood the CONTRIBUTING guidelines and have don...
CocoaPods Bug with Unit Tests on Mojave: "The bundle couldnโ€™t be loaded because it is damaged or missing necessary resources"
i was able to workaround this by reverting to the legacy build system for now to get the UI tests ru...
CocoaPods pod search AFNetWorking
Can you try removing search_index.json and run search command again? I'd be happy if you send the ou...
CocoaPods Signing for requires a development team. Select a development team in the Target Editor. in Xcode 8 and Swift 3. ๐ŸŒˆ
I know it's a bit self explanatory but to make the project actually build again select a Development...
CocoaPods Playgrounds regression between CocoaPods 1.4.0 and CocoaPods 1.5.0
@dnkoutso The workaround suggested above (@litmanenPL) does resolve the issue ๐ŸŒˆ I've read and under...
CocoaPods 'Pod Spec Lint' failed validation
Confirmed this is the same as #8116 This worked and I was able to lint successfully Please remove In...
CocoaPods Current CocoaPods should be installable on Mojave without dependency upgrades
Here's an annotated transcript of my console session reproducing the problem I've also discovered th...
CocoaPods Pushing spec fails with Xcode 10 GM
Run gem install cocoapods --pre to install beta version 1.6.0.beta.1 fixes the issue for me ...
CocoaPods RuntimeError - [Xcodeproj] Unknown object version.
you are on a very old version of cocoapods please update to latest version and also gem update xcode...