新MAC安装CocoaPods(发现没有homebrew,出现错误)

1.先安装新版Xcode

2.配置rvm ($为终端自带,不用copy)

   rvm是一个便捷的多版本 ruby 环境的管理和切换工具

   在终端控制台命令:

$  curl -sSLhttps://get.rvm.io| bash -s stable之后按回车键

3.安装 ruby

列出 ruby 可安装的版本信息 (这里安装的是 2.4.4 的)

$ rvm list known

结果为:

# MRI Rubies

[ruby-]1.8.6[-p420]

[ruby-]1.8.7[-head]# security released on head

[ruby-]1.9.1[-p431]

[ruby-]1.9.2[-p330]

[ruby-]1.9.3[-p551]

[ruby-]2.0.0[-p648]

[ruby-]2.1[.10]

[ruby-]2.2[.10]

[ruby-]2.3[.7]

[ruby-]2.4[.4]

[ruby-]2.5[.1]

[ruby-]2.6[.0-preview2]

ruby-head

安装一个ruby版本

$ rvm install 2.4.4 (也可尝试安装2.6.0 我没有尝试)

如果想设置为默认版本,可以用这条命令来完成

$ rvm use 2.4.4 --default

如果出现以下结果,则没有安装homebrew

No binary rubies available for: osx/10.13/x86_64/ruby-2.4.4.

Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.

Checking requirements for osx.

About to install Homebrew,press `Enter` for default installation in `/usr/local`,

type new path if you wish custom Homebrew installation(the path needs to be writable for user)

: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

mkdir: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)": Operation not permitted

Requirements installation failed with status: 1.

安装Homebrew,通过命令行即可,打开终端输入

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

 出现下面内容即OK   

==>Migrating /Library/Caches/Homebrew to /Users/tiantian/Library/Caches/Homebrew...

==>Deleting /Library/Caches/Homebrew...

Already up-to-date.

==> Installation successful!

安装homebrew后,再次执行    $ rvm install 2.4.0

直到出现

ruby-2.4.4 - #adjusting #shebangs for(gem irb erb ri rdoc testrb rake).

Install of ruby-2.4.4 - #complete

安装ruby成功

4.     最后就是最重要的安装cocoapods了

 $ sudo gem install cocoapods

Done installing documentation for nanaimo,colored2,claide,CFPropertyList,xcodeproj,ruby-macho,nap,molinillo,gh_inspector,fourflusher,escape,cocoapods-try,netrc,cocoapods-trunk,cocoapods-stats,cocoapods-search,cocoapods-plugins,cocoapods-downloader,cocoapods-deintegrate,fuzzy_match,thread_safe,tzinfo,i18n,activesupport,cocoapods-core,cocoapods after 19 seconds

意味你安装成功了!!!

你可能感兴趣的:(新MAC安装CocoaPods(发现没有homebrew,出现错误))