First, the introduction of the development of iOS applications, often use some third-party open source class libraries, such as Jsonkit, afnetworking, QRCode and so on. A class library may also reference other class libraries. Manual to load each other seems to be more troublesome. And Cocoapods is used to solve the class library reference is always, it is similar to PHP on the composer, Java maven, perhaps with the Linux platform Apt-get command also have similarities. Website address: https://cocoapods.org
Second, the installation of cocoapods need to install the Ruby environment, the default should be installed, here no longer describes the Ruby installation method, the direct introduction of Cocoapods installation. Command Line Input
sudo gem install Cocoapods
If you enter a password for a long time no response, or the hint can not be found, the address may be wall, then first enter:
Gem sources--remove https://rubygems.org///and so on and then typed the following command gem Sources-a http://ruby.taobao.org/
<p style= "margin-top:0px; margin-bottom:0px; font-size:11px; Font-family:monaco; Color:rgb (115, 115, 115); " >gem sources-l</p>
Change the mirror to the mirror of the domestic Taobao.
At this point the interface output:
Current SOURCES ***http://ruby.taobao.org/
Execute the installation command again. After the installation is done
Pod Install command----I don't know what the order is for the time being.
Iii. using Example 1. Reference QRCode in the project first verify that QRCode supports Cocoapods
Pod Search Qrcodereaderviewcontroller
Output:
Qrcodereaderviewcontroller (3.4.0) Simple QRCode Reader for IOS 7 and over pod ' Qrcodereaderviewcontroller ', ' ~> 3.4.0 ' -Homepage:https://github.com/yannickl/qrcodereaderviewcontroller -Source: https://github.com/yannickl/QRCodeReaderViewController.git -versions:3.4.0, 3.3.0, 3.2.3, 3.2.2, 3.2.1, 3.2.0, 3.1.0, 3.0.0, 2.0.0, 1.0.1, 1.0.0 [master repo]
To the project's. Xcodeproj directory, build the Podfile file:
Touch Podfile
Vim Podfile
<pre name= "code" class= "plain" >source ' https://github.com/CocoaPods/Specs.git ' Platform:ios, ' 7.0 ' pod ' Qrcodereaderviewcontroller ', ' ~> 3.4.0 '
After saving, enter the command:
Pod Install
When the installation is complete, enter the command:
Open Myproject.xcworkspace
Open the project and do not open the project with. Xcodeproj.
When you need to upgrade an open source library for later use, you only need to enter: Pod update to automatically complete the update.
Use of IOS Package management tool Cocoapods