Third-party class library management tools in iOS development-cocoapods-

Source: Internet
Author: User
Tags install cocoapods

Reprint Please specify source: http://blog.csdn.net/whjForWork/article/details/44967891

What is Cocoapods?
    • When you need to use a third-party open source class library in an iOS project, or if the class library you are using needs to be updated, it is cumbersome to re-download it, but with cocoapods, we can solve the problem with a single line of command.

    • CocoaPods is a tool for managing third-party open source code in iOS projects, cocoa using Ruby, whose source code is open source on GitHub https://github.com/CocoaPods/CocoaPods

    • Cocoapods can save time in setting up and updating third-party open source libraries and increase productivity

Introduction to the use of cocoapods
    • GEM is a standard package for managing Ruby libraries and programs that can be found, loaded and unloaded by gems
Installing Cocoapods
    • First enter the following command in the terminal,
      • sudo gem sources–remove https://rubygems.org/
    • After the reaction, enter the following line
      • sudo gem sources-a http://ruby.taobao.org/
    • Then enter this line to view the address
      • Gem Sources-l
    • If a prompt similar to the following appears, represent OK

    • Install the Cocoapods Toolkit, enter the following command in the terminal, the installation process due to network problems will be slow, please wait patiently

      • sudo gem install Cocoapods
    • Enter the following command in the terminal, initialize

      • Pod Setup
      • The occurrence of a character indicates a successful initialization

    • In the terminal input pod search AFN, you can see the version of the framework, download the GIT address

    • If the installation is not successful, upgrade the gem

      • sudo gem Update–system
Project using pods to create a new project using Xcode
    • Terminal switch to project using POD init to create a podfile file

    • Edit the Podfile file, enter the sudo vi podfile, and then import the AFN frame as shown in the left image and save

? * then enter pod install to add the relevant framework to the project, before executing the command, the Xcode and the simulator are closed

    • The following prompt appears, the representative has been integrated into your project, due to network reasons, may download a bit slow

    • Then open the Pods demo. Xcworkspace to run the project, remember not to open the pods demo. Xcodeproj

    • All dependencies have been added and we are going to import the header file to use

    • Note The format of the import header file can only be imported using angle brackets

Summarize:
    • Pods all dependencies are configured according to the Podfiles file

    • To configure the framework, you can specify the configuration number pod ' Sdwebimage ', ' ~> 0.2.0 ', but not usually specified, and the most recent version number used

    • When there is a framework update, switch to the project at the terminal, and then run the pod Update command to

    • If you are appending a third-party framework, search the framework, and then write Podfile, using the pod Install command

      • The added will be displayed in the location shown

    • The following are the common gem commands
      ????????????????????

Third-party class library management tools in iOS development-cocoapods-

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.