iOS经验总结

2021-02-03关于2021年2月mac第一次安装cocoa

2021-02-03  本文已影响0人  三年_b05b

macOS:12.2 cocoapods版本:1.10.1 ruby:2.7.0

安装最新版cocoapods时,pod install时出现下列问题:

/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.0.rc2/lib/active_support/multibyte/unicode.rb:123:in `normalize': undefined method `squish' for #<String:0x00007fe91b0712a8> (NoMethodError)

愿意时需要升级Ruby,系统默认的是2.6.3

尝试用RVM升级Ruby

http://blog.csdn.net/lissdy/article/details/9191351

如果碰到下面问题

Searching for binary rubies, this might take some time.

No binary rubies available for: osx/10.11/x86_64/ruby-2.2.4.

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

Error running ‘requirements_osx_brew_update_system ruby-2.2.4‘,

先运行下面命令,再安装:

rvm autolibs read-only

1、需要提前安装homebrew、RVM、Ruby等;步骤可以百度;当安装rvm时会出现Warning! PATH is not properly set up, /Users/ios-oc/Software/ruby/bin is not at first place.  的问题是因为输入了rvm 的操作 ;

下载ruby的时候会提示去一个log文件里查看失败信息 其中包含cannot load such file -- openssl (LoadError);

这时候需要重新去下载OpenSSL :终端操作:% rvm pkg install openssl    首先需要下载openssl,提示成功后输入 

rvm reinstall ruby-2.7.0 --with-openssl-dir=$rvm_path/usr

可以选择自己想要下载的ruby版本 ruby -v 查看版本;

2、这时,输入pod -v 提示:

Traceback (most recent call last):

2: from /usr/local/bin/pod:23:in `<main>'

1: from /Library/Ruby/Site/2.6.0/rubygems.rb:300:in `activate_bin_path'

/Library/Ruby/Site/2.6.0/rubygems.rb:281:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)

需要输入:rvm get stable 

最后安装cocoapods:gem install cocoapods   安装成功。

ps:路径:/user/ios-oc(本机地址)/.bash_profile;

sudo chmod -R +rx /usr/bin    添加读写权限

彻底删除cocoapods:sudo gem uninstall -n /usr/local/bin cocoapods

显示隐藏文件命令行:https://blog.csdn.net/qq_32666701/article/details/80607646 

1、期间在.bash_profile文件中 增加了export PATH="/usr/local/opt/ruby/bin:$PATH"  还有两行不确定是否添加我全部贴出来了:

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

export GEM_HOME=$HOME/Software/ruby

export PATH=PATH:PATH:HOME/Software/ruby/bin

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

export PATH="/usr/local/opt/ruby/bin:$PATH"

2、.bashrc文件如下:

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

# for brew install

export PATH=/usr/local/bin:$PATH

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

export PATH=/usr/bin/ruby:$PATH

还有最后借鉴:https://www.wddsss.com/main/displayArticle/230下面是内容:

首先需要在 Mac 中安装 Ruby 环境rvm

1: 安装rvm 和nvm类似,用于管理Ruby的版本

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

2: 下载成功后设置环境变量

source~/.rvm/scripts/rvmrvm-v //检查是否设置成功

3: 设置Ruby china镜像

echo"ruby_url=https://cache.ruby-china.org/pub/ruby"> ~/.rvm/user/db

安装 Ruby

1: 查询可安装版本

rvmlist known

当前最新版本为 2.7.0

2: 开始安装

rvminstall2.7.0

3: 检验安装

ruby-v

安装cocoaPods

1: 开始安装

geminstall cocoapods

2: 检验安装

pod-v

上一篇 下一篇

猜你喜欢

热点阅读