CocoaPods is a powerful tool for managing Objective-C third-party libraries.

Source: Internet
Author: User
Tags install cocoapods
Document directory
  • Search
  • Initialization
  • Add a Library:
  • Header file path
  • Other third-party libraries.
Introduction:

Third-party libraries are indispensable during application development, which can improve the development efficiency. Some frequently used libraries are used in new projects. You have to manually Add them to the Project and use multiple libraries, which makes it inconvenient to manage them. CocoaPods can help you manage third-party libraries in Xcode.

How can this problem be used? Install CocoaPods first.

1. CocoaPods is a software running in Ruby. It may take several minutes to install it. The installation name is as follows:

Sudo gem install cocoapods

2. If you want to generate a document for each third-party library, run

Brew install appledoc is optional.

After the installation is complete, the following message is displayed:

If your Ruby environment is not new enough, you may need to update it:

Gem update -- system

How can I use the pod after it is installed? Search

First try the search function. You can use the pod to search for the library you need, for example, the JSONKit Library:

Pod search is the name of the search, followed by the name of the database.

Pod search JSONKit

Search:

Initialization

Okay. In the terminal shell, cd comes to the project you want to manage and run: pod install

After running, you will find that your project directory is like this:

*. Xcworkspace pod and other files are added. This is the project management file generated by the pod. Open the LibDemo. xcworkspace project file and see the following directory structure in Xcode:

Add a Library:

Vim Podfile open the file and add the JSONkit you just searched to it.

Platform: ios
Pod 'jsonkit'

Save and exit.

Run: pod update

In this way, the JSONKit library is downloaded and associated with the local project. This is why Xcode prompts you to update the project.

Click Revert.

At this time, you can see that the pod part of the project is added with the JSONKit library. Well, the third-party library is so magical.

Header file path

Try using JONSKit. h and reference it in ViewController. m. What should I do if I cannot find the header file? The Directory of the header file has not been set. Set it in the Target of the project:

As shown in, select recursive after $ {SRCROOT.

In the reference header file:

Perfect.

Other third-party libraries.

After the Podfile file is added, it will be OK under pod update.

platform :ios, '5.0'pod 'JSONKit'pod 'AFNetworking'pod 'MBProgressHUD'pod 'Reachability'pod 'Nimbus/Core'

For example, if I reference the above libraries, Nimbus is too large. I only need Core and can write it like this.

CocoaPods also has many advanced functions that can be used as needed.

Reference: https://github.com/CocoaPods/CocoaPods/wiki

 

Rong Fangzhi (http://blog.csdn.net/totogo2010)

This article follows the "signature-non-commercial use-consistency" creation public agreement

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.