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

Source: Internet
Author: User
Tags install cocoapods

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

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.

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.