The installation of cocoapods and the solution to the problems encountered in the installation - installing RVM

This is not the first time to install cocoapods, but today I installed cocoapods on my mac pro  Error installing pods:active support requires Ruby version >= 2.2.2
before the installation did not have this problem. After checking the information for a long time, I found that the version of ruby ​​was too low, and I needed to follow the new Ruby. Then one after another The pit appeared.

First of all, to update Ruby, there are three options:
1. Download ruby ​​source code, compile, install
2. Use the installation package that comes with the distribution, install
3. Use rvm to install

I chose rvm installation, it is bound to install rvm first

1. RVM: Ruby Version Manager, Ruby version manager, including Ruby version management and Gem library management (gems)
$ curl -L get.rvm.io | bash -s stable
2. Load the file, test whether the installation is normal (follow the prompts)
$ source ~/.bashrc $ source ~/.bash_profile $ source ~/.profile$ rvm -v
3. If there is the following prompt, please reload rvm
A RVM version 1.27.0 (latest) is installed yet 1.25.23 (stable) is loaded.
Please do one of the following:

  • 'rvm reload'
  • open a new shell
  • 'echo rvm_auto_reload_flag=1 >> ~/.rvmrc' # for auto reload with msg.
  • 'echo rvm_auto_reload_flag=2 >> ~/.rvmrc' # for silent auto reload.

input the command:

$ rvm reload
$ rvm -v
4. Check the current ruby ​​version and get the rvm list

$ ruby -v $ rvm list known


5. Possible errors in installing ruby ​​(if no errors, please skip to step 6)

$ rvm install 2.3
Error 1: When installing ruby, the following error may be reported, prompting Updating system[YourMacName] password required for ‘port -dv self update’

Solution:
make an update:

$ sudo port self update

Error 2:
Or you may encounter the following error because Homebrew needs to be installed.
Error running 'requirements_osx_port_libs_install curl-ca-bundle automake libtool libyaml libffi libksba',showing last 15 lines of /Users/acewill/.rvm/log/1468253599_ruby-2.3.0/package_install_curl-ca-bundle_automake_libtool_libyaml_libffi_libksba.log

Solution:
Refer to the question on stack overflow Installing RVM: "Requirements installation failed with status: 1."

Homebrew needs to be installed, via the following command:

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

6. Reinstall ruby
​​After the installation is complete, re-execute the command to install cocoapods.

$ rvm install 2.3
7. Install rails

$ gem install rails
8. Uninstall ruby ​​method
to get ruby ​​installed list, then uninstall ruby

$ rvm list$ rvm remove 2.3

After configuring ruby, you can finally install cocoa pods, and the next operation is the same as before

$ gem sources -l (view current ruby ​​sources)
$ gem sources --remove  https://rubygems.org/
$ gem sources -a  https://ruby.taobao.org/
$ gem sources -l
2. Then re Execute the installation download command
$ sudo gem install cocoapods
Execute the pod install command

Setting up CocoaPods master repo appears, indicating that Cocoapods is downloading its information to ~/.cocoapods;

$ pod setup
(if there is a problem when executing pod setup, pay attention to the format in the podfile file and change it to:

platform :ios, '8.0'
target '你的项目名称' do
pod 'AFNetworking', '~> 3.1.0'
end

)
Terminal will stay in the Setting up CocoaPods master repo state for a while, because the download and installation is required, and the directory is relatively large, so you need to wait patiently. If you want to speed up the speed, you can use the mirror index of cocoapods.
How to use the mirror index of CocoaPods :
The Podspec files of all projects are hosted at https://github.com/CocoaPods/Specs. When the pod setup is executed for the first time  , CocoaPods will update these podspec index files to the local ~/.cocoapods directory. This index file It is relatively large, so the first update is very slow. Friendly people have established a mirror of the Cocoapods index library on the domestic server, so it will be much faster to perform index and new operations. The specific operation method is as follows: $ pod repo remove master
$ pod repo add master  https://gitcafe.com/akuandev/Specs.git
$ pod repo update
This is to use the mirror on gitcafe,   replace  https://gitcafe.com/akuandev/Specs.git in the above code with https:/ /git.oschina.net/akuandev/Specs.git  can use the mirror on oschina.

cd project directly into
pod init, generate Podfile file
pod search afn search keyword supports fuzzy query MJre

Then find the pod file in the project and copy the things to be installed

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324768449&siteId=291194637