Mac使用React-Native开发iOS 执行pod install报错

在ios文件夹里执行pod install时报以下错误:

Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
[!] `React` requires CocoaPods version `>= 1.10.1`, which is not satisfied by your current version, `1.9.1`.

我当前的cocoapods版本为1.9.1,提示我需要升级到1.10.1版本

于是使用如下命令更新cocoapods:

sudo gem install -n /usr/local/bin cocoapods

更新cocoapods时报如下错误:

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

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20210325-11884-bs1byv.rb extconf.rb
*** 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.

解决方案:

1.安装rvm:

curl -L https://get.rvm.io | bash -s stable

2.安装或更新ruby(我这里是2.7.2,大家自行选择版本):

rvm install 2.7.2

安装ruby时报如下错误:

No binary rubies available for: osx/10.15/x86_64/ruby-2.7.2.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Installing requirements for osx.
Updating system - please wait
Failed to update Homebrew, follow instructions at

    https://docs.brew.sh/Common-Issues

and make sure `brew update` works before continuing.
Error running 'requirements_osx_brew_update_system ruby-2.7.2',
please read /Users/zhouhailin/.rvm/log/1616680773_ruby-2.7.2/update_system.log
Requirements installation failed with status: 1.

此时执行:

rvm autolibs read-only

然后再更新ruby:

rvm install 2.7.2

出现以下界面,即安装成功:

Requirements installation successful.
Installing Ruby from source to: /Users/zhouhailin/.rvm/rubies/ruby-2.7.2, this may take a while depending on your cpu(s)...
ruby-2.7.
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值