iOS Development Cocoapods installation (2017)

Source: Internet
Author: User
Tags git clone install cocoapods

Because the image of Taobao is not maintained, so recently saw a 2,107-year cocoapods installation blog mark



First step: Install RVM,

Whether or not you need to upgrade RUBY,RVM allows you to have multiple versions of Ruby, and you can switch between multiple versions freely. If you have already installed skip to step 2nd (Rvm-v to see if it is installed)

$ curl-l Get.rvm.io | Bash-s Stable

Need to wait a while

$ source ~/.BASHRC

$ source ~/.bash_profile

Wait for the terminal to load, and then enter

Rvm-v

If you can display a good version, the installation is successful. Step two: Install Ruby

Cocoapods current installation requires Ruby version greater than 2.2.2, or it will error: Error installing pods:activesupport requires Ruby version >= 2.2.2. The current MAC system defaults to 2.0, so it needs to be upgraded.

To view installed Ruby:

RVM List

If the installed version is greater than 2.2.2, go straight to step 3rd.

RUBY-V//can also view Ruby version

Lists the version information that Ruby can install

RVM list known

RVM Install 2.2.2//install a ruby version

This must be set to the default version

RVM Use 2.2.2--default

Step Three: replace the source

We need to modify the replacement source (due to the domestic wall) so we have to switch the source to Ruby-china. Execute the following command at the terminal

Now most of the online articles are this:

$ sudo gem update--system

$ gem Sources--remove https://rubygems.org/

Wait for a response, and then typing the following command

$ gem sources-a https://ruby.taobao.org/

This is a big pit: it's going to be an error. _connect returned=1 errno=0 State=sslv3 Read Servercertificateb:certificate verify failed (https:// ruby.taobao.org/specs.4.8.gz)

This is because the Taobao Gems source has stopped maintenance and is now provided by the Ruby-china mirroring service, and the correct action is:

$ sudo gem update--system

$ gem Sources--remove https://rubygems.org/

$ gem Sources--remove https://ruby.taobao.org///If Taobao image is installed

Wait for a response, and then typing the following command

Gem Sources-a https://gems.ruby-china.org/

To verify that your Ruby mirror is and is only Ruby-china, you can view it with the following command:

$ gem sources-l

Only the following text appears in the terminal to indicate that your command was successful:

Current SOURCES * * *

https://gems.ruby-china.org/

# Make sure only gems.ruby-china.org

Fourth Step: Install Cocoapods

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

One more word, perfect solution.

sudo xcode-select--switch/applications/xcode.app

Enter the following command in the terminal to complete the installation:

Pod Setup

It takes a little time to finish, I'm hanging up anyway. Wait a night.

If the installation fails ~/.cocoapods the inside is empty, you will need to reset the setup

The order is as follows:

Pod Repo Remove Master

Pod Setup

After the completion of this folder is about 100 m, it will take more time, please be patient.

Here you have successfully installed the Cocoapods Ultimate Solution: You have installed your Cocoapods colleague ~/.cocoapods directory under the Repo directory copy down, put into your own directory. Re-pod Setup

to determine whether the cocoapods can be used, you can use the Cocoapods search function to verify. In the terminal, enter:

$ pod Search afnetworking

After a while (probably longer), you will see some red error messages in the terminal, as follows:

Setting up Cocoapods master Repo

[!] /usr/bin/gitclone ' Https://github.com/CocoaPods/Specs.git ' master--depth=1

Cloning into ' master ' ...

Error:rpc failed; result=52, HTTP code = 0

Fatal:the remote end hung up unexpectedly

This means that cocoapods is not working properly, needs to update pod, downloads some of its dependencies, and enters in the terminal:

$ pod Setup

After a while, you will see the same red error message in the terminal.

When the above command is typed, this is the way on the small end (because it is too long to intercept only the previous part):

This indicates that some environmental reasons have caused the pod to be updated, possibly because 1 gem versions are too low, 2 GitHub cannot be linked, and 3). The configuration information in the Cocoapods directory is incorrect. We can rule it out by one.

First, update the gem to the latest version and enter it in the terminal:

$ sudo gem update--system

Then check to see if you can ping the GitHub and enter it in the terminal:

$ ping github.com

Then view the POB repo list:

$ pod Repo list

The results showed 0 repos, indicating no successful installation;

Delete the. cocoapods directory and download the pod update again:

$ CD ~/.cocoapods/

$ SUDO-RM-RF ~/.cocoapods/

Re-execute POD setup, after a period of time prompted the setup completed, in the terminal input Pod list, display the installation list;

When the above command is typed, this is the way on the small end (because it is too long to intercept only the previous part):

Error Agent

[!] /usr/bin/git Clone Https://github.com/CocoaPods/Specs.git Master--depth=1

Cloning into ' master ' ...

Fatal:unable to access ' https://github.com/CocoaPods/Specs.git/': Failed to connect to proxy.com Port 1234:operation Tim Ed out

Obviously Ah, should be bad, this song means: Agent appeared problems, resulting in cloning does not come down, research for a long time, so there are two ways to 1 "modify the agent such as: git config--global http.proxy 192.168.1.1:8081 (written by this agent) 2 "

git config--global http.proxy query to the agent currently set, so cancel this setting: Git config--global--unset http.proxy
Re-query, has no agent, after the successful installation.

See here, your heart will say, I am. It's so cool, it's finally downloaded and installed. Next see how to use it. let's start by creating this magical podfile. In the terminal, enter (CD command) your project directory, and then in the current directory, using Vim to create Podfile, run:

$ vim Podfile

Then enter the following text in the Podfile file: It is necessary to note that the format of the input in the podfile has changed.

Platform:ios, ' 8.0 '

Target ' your project name ' Do

Pod ' afnetworking ', ' ~> 3.1.0 '

End

Then save the exit. In the VIM environment, the Save Exit command is:

: Wq

At this point, you will find a file with the name Podfile in your project directory, and the content of the file is what you just entered. Note that the Podfile file should be in the same directory as your project file. Xcodeproj.

At this point, you can use Cocopods to download the Afnetworking class library. Or in the current project directory in the terminal, run the following command:

$ pod Install

Recently, Cocoapods was used to add a Third-party class library, either by performing pod install or by pod Update, which is stuck in the analyzing dependencies does not move

The reason is that when executing the above two commands will upgrade the Cocoapods spec warehouse, add a parameter can omit this step, and then the speed will increase a lot. The command for the parameter is as follows:

$ pod Install--verbose--no-repo-update 
$ pod Update--verbose--no-repo-update

Note the last sentence, meaning: Open the project later with the Cocoapodsdemo.xcworkspace open, rather than the previous. xcodeproj file. Otherwise you cannot associate the class library of pod down. Turn from: http://blog.csdn.net/e62ces0iem/article/details/73550884

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.