在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.