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

升级cocoapods 出现如下错误信息

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 -I /Library/Ruby/Site/2.3.0 -r ./siteconf20200303-68332-1cf9u3w.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

尝试了升级cocoapods需要一个正确的操作流程和命令以下语句

1、更新gem:sudo gem update --system

2、删除gem源:gem sources --remove https://ruby.taobao.org/

3、修改gem源:gem sources -a https://gems.ruby-china.com

4、查看gem源是否是最新的:gem sources -l

5、升级cocoapods:sudo gem install -n /usr/local/bin cocoapods

6、查看升级后的cocoapods版本:pod --version

还是没有成功。

wangpeideMacBook-Pro:~ wangpei$ rvm -v
-bash: rvm: command not found

用命令 rvm 命令发现问题如下:-bash: rvm: command not found

执行 \curl -sSL https://get.rvm.io | bash -s stable --ruby 

wangpeideMacBook-Pro:~ wangpei$ \curl -sSL https://get.rvm.io | bash -s stable --ruby
Downloading https://github.com/rvm/rvm/archive/1.29.9.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.9/1.29.9.tar.gz.asc
Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.29.9/1.29.9.tar.gz.asc',
but no GPG software exists to validate it, skipping.
Upgrading the RVM installation in /Users/wangpei/.rvm/
    RVM PATH line found in /Users/wangpei/.mkshrc /Users/wangpei/.profile /Users/wangpei/.bashrc /Users/wangpei/.zshrc.
    RVM sourcing line found in /Users/wangpei/.profile /Users/wangpei/.bash_profile /Users/wangpei/.zlogin.
Upgrade of RVM in /Users/wangpei/.rvm/ is complete.

Thanks for installing RVM 
Please consider donating to our open collective to help us maintain RVM.

  Donate: https://opencollective.com/rvm/donate


Ruby enVironment Manager 1.29.9 (latest) (c) 2009-2017 Michal Papis, Piotr Kuczynski, Wayne E. Seguin

ruby-2.6.3 - #removing src/ruby-2.6.3..
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.14/x86_64/ruby-2.6.3.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.

执行 source /Users/XXXXXX/.rvm/scripts/rvm启动rvm


  * To start using RVM you need to run `source /Users/wangpei/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
wangpeideMacBook-Pro:huobicloud_ios wangpei$ source /Users/wangpei/.rvm/scripts/rvm

rvm use ruby-2.6.3

执行安装cocoapods 命令sudo gem install cocoapods 或者sudo gem install -n /usr/local/bin cocoapods

ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://gems.ruby-china.com/ - no such name (https://gems.ruby-china.com/specs.4.8.gz)
ERROR:  Possible alternatives: cocoapods
wangpeideMacBook-Pro:~ wangpei$ gem sources -l
*** CURRENT SOURCES ***

https://gems.ruby-china.com/
wangpeideMacBook-Pro:~ wangpei$ sudo gem update --system
Latest version already installed. Done.
wangpeideMacBook-Pro:~ wangpei$ sudo gem install -n /usr/local/bin cocoapods
Successfully installed cocoapods-1.9.2
Parsing documentation for cocoapods-1.9.2
Done installing documentation for cocoapods after 1 seconds
1 gem installed
wangpeideMacBook-Pro:~ wangpei$ pod --version
1.9.2

 

你可能感兴趣的:(iOS优化)