Errors when installing cocoapods with gem

后端 未结 7 1992
旧巷少年郎
旧巷少年郎 2021-02-04 01:41

I am using macOS Mojave and when I try to install cocoapods using gem I am getting the following error.

Building native extensions. This could take a whi

相关标签:
7条回答
  • 2021-02-04 02:14

    just spent my day figuring out solution, I am using MacOS Big Sur Beta 8. to upgrade cocoapods with gem, try this:

    1. install rbenv
    • git clone https://github.com/rbenv/rbenv.git ~/.rbenv

    • cd ~/.rbenv && src/configure && make -C src

    • Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility. see: https://github.com/rbenv/rbenv#basic-github-checkout

    • make sure export PATH="$HOME/.rbenv/shims:${PATH}" was added to your $PATH

    1. xcode-select --switch /Applications/Xcode.app/Contents/Develope

    2. gem install cocoapods should work like a charm!

    0 讨论(0)
  • 2021-02-04 02:16

    This helped/ worked for me like charm:

    # brew cleanup -d -v    
    # brew install cocoapods
    

    P.S.: You should have Homebrew installed. You can use below command to install brew:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    

    Good luck :)

    0 讨论(0)
  • 2021-02-04 02:21

    For me use a command sudo gem install cocoapods -v 1.8.4 instead of sudo gem install cocoapods

    Reference: https://github.com/CocoaPods/CocoaPods/issues/9568#issuecomment-599235420

    0 讨论(0)
  • 2021-02-04 02:27
    sudo xcode-select --switch /Library/Developer/CommandLineTools
    
    ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'
    
    0 讨论(0)
  • 2021-02-04 02:27
    1. Run
      ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'
      
      to figure out your ruby configuration.
    2. If the output is a nonexistent MacOSX10.15 path. Like
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0
      
      then you should correct the configuration by doing next step.
    3. Run
      sudo xcode-select --switch /Library/Developer/CommandLineTools
      
    4. You can run
      ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'
      
      again to see if the path has changed.
    5. The output should be something like
      /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0
      

    Now you can run gem install to install cocoapods!

    0 讨论(0)
  • 2021-02-04 02:34

    The answer for this can be found here here although it is unrelated to this question. Below is a snippet of the answer which works best.

    For Xcode 11 on macOS 10.14, this can happen even after installing Xcode and installing command-line tools and accepting the license with

    sudo xcode-select --install
    sudo xcodebuild -license accept
    

    The issue is that Xcode 11 ships the macOS 10.15 SDK which includes headers for ruby2.6, but not for macOS 10.14's ruby2.3. You can verify that this is your problem by running

    ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'
    

    which on macOS 10.14 with Xcode 11 prints the non-existent path

    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0
    

    However, Xcode 11 installs a macOS 10.14 SDK within /Library/Developer/CommandLineTools/SDKs/MacOS10.14.sdk. It isn't necessary to pollute the system directories by installing the old header files as suggested in other answers. Instead, by selecting that SDK, the appropriate ruby2.3 headers will be found:

    sudo xcode-select --switch /Library/Developer/CommandLineTools
    ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'
    

    This should now correctly print

    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0
    

    Likewise, gem install should work while that SDK is selected.

    To switch back to using the current Xcode 11 SDK, use

    sudo xcode-select --switch /Applications/Xcode.app
    
    0 讨论(0)
提交回复
热议问题