Use of Cocoapods

Source: Internet
Author: User

How to download and install Cocoapods.

1. Use Taobao's ruby image to access the cocoapods. Click the command in the terminal in the following order:

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

Wait until you have a response, and then typed the following command

$ gem sources-a https://ruby.taobao.org/(Note is HTTPS)

In order to verify that your ruby image is and is only Taobao, you can view it with the following command:

$ gem sources-l

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

Current SOURCES * * *

http://ruby.taobao.org/


2. Use the following command to upgrade the Ruby version:


Gem Update--system

After waiting for the update to complete


3. Then use the Gem command to download the installation Cocoapods:



Gem Install cocoapods (if the command is not successfully added sudo) sudo gem install-n/usr/local/bin cocoapods

4. After the installation is complete, call the following command to set the Cocoapods:


Pod Setup

Execution completes the above command, indicating that the installation was successful. The following describes how to use Cocoapods.


The setting up CocoaPods master repo appears (this hint is a hint that is being installed), stating that CocoaPods is downloading its information to ~/.cocoapods;

CD into this directory, with the DU-SH * command to view the file size, every few minutes to view, the final size of the directory is more than 100 m, is completed

--------------------------------------------------------------------------------------------

How to use Cocoapods.

Well, after installing the Cocopods, the next step is to use it. Fortunately, using Cocopods is as simple as installing it, and it can be done with one or two lines of command.

Here are two usage scenarios to specify how to use Cocoapods.

Scenario 1: Import the Afnetworking class library into your project with Cocoapods

Afnetworking class Library at GitHub address is: https://github.com/AFNetworking/AFNetworking

To determine if afnetworking supports Cocoapods, you can verify it with the Cocoapods search function. In the terminal, enter:

$ pod Search afnetworking

Let's start by creating this magical podfile.

$ cd command your project directory, and then in the current directory, using pod to create Podfile, run:

$ pod Init

You will find a podfile file below the current directory

Open the Podfile file using Xcode and edit the following

# Platform:ios, ' 9.0 '

Target ' XUWB ' do


# Comment The next line if your ' re not using Swift and don ' t want to use dynamic frameworks
use_frameworks!


# Pods for XUWB
Pod ' afnetworking '
Pod ' Sdwebimage '
Pod ' Snapkit '
Pod ' Svprogresshud '


End

The version number is not followed by the default download is the latest

Pod ' afnetworking ', ' ~> 3.1.0 '
Pod ' sdwebimage ', ' ~> 3.7.5 '
Pod ' Snapkit ', ' ~> 0.19.1 '
Pod ' Svprogresshud ', ' ~> 1.1.3 '. To download the specific version, the format must be based on Pod search.

If you do not want Cocoapods to automatically update the version number, you can use the command pod install--no-repo-update

If you want to know the version of the framework that cocoapods imported, you can use Xcode to open the Podfile.lock file

Note: Be sure to follow this format, otherwise you will get an error isnot Usedin any concrete target.


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, under the current project directory in the terminal, run the following command:

$ pod Install

A summary is: 1. Creating Podfile,podfile in your project first is the class library you want to import. The original author of the General class Library will tell you how to write podfile for importing such libraries; 2. Run the command: Pod install.

Below, the small part continues to describe the second usage scenario.

Scenario 2: How to compile and run a project that contains the Cocopods class library correctly

Enter the directory where the Uaappreviewmanagerexample is located, that is, and podfile in the same directory, and scene 1, enter the following life (because there is already podfile, so there is no need to create Podfile):

$ pod Update

After a few seconds (which may take more than 10 seconds depending on your network condition), the terminal appears:

Analyzing dependencies

Fetching Podspec for ' Uaappreviewmanager ' from '. /`

Downloading dependencies

Installing Uaappreviewmanager (0.1.6)

Generating Pods Project

Integrating client Project


[!] From "On" Use ' uaappreviewmanagerexample.xcworkspace '.


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.