CocoaPods: manages various third-party open source library associations in the Objective-c program

Source: Internet
Author: User

CocoaPods: manages various third-party open source library associations in the Objective-c program
In our iOS program, multiple third-party open-source libraries are often used. The common practice is to download the latest open-source library and drag it to the project. However, once the number of third-party open-source libraries is large, version management is very troublesome. Is there any way to simplify the management of third-party libraries? Yes! When using SDWebImage as a third-party library, I learned how to display the progress. Someone mentioned that using CocoaPods (http://cocoapods.org/, FQ) to manage third-party open-source libraries. CocoaPods is a great way to manage the association of various third-party open-source libraries in the Objective-c program. As long as CocoaPods is installed, a Podfile text is created under the root directory of your program, this section describes the kits to be used, and CocoaPods will help you deal with the dependency of all the kits. Now let's learn how to use CocoaPods. CocoaPods installation is a Ruby Gem, so you only need to run the Security Command: gem install cocoapodspod setup in Terminal. Note: you may feel unresponsive when executing code, it may take some time. Please wait. After installation, check whether the installation is complete. search for a third-party open-source Library: pod search SDWebImage. The result is shown in. If no error or other information is reported, CocoaPods is successfully installed. Okay, let's see how to use it. For example, if you want to use the SDWebImage open source library, you can use the command: pod search SDWebImage to search for the number of SDWebImage versions and related information for each version. Select the desired version and add it to the Podfile file. There are two ways to add an open-source library to a Podfile: method 1 (manually create a Podfile file): Create a text file named Podfile under the root directory of your project; then, set the text in the red box (pod 'sdwebimage', '~> 3.4 ') copy it in, save it, and then remove the extension name of the text document (an error will occur if there is a suffix, for test ). Method 2: first go to the root directory of your project (because the document needs to be created here), and then edit the Podfile document (if Podfile exists, edit it, the text in the red box (pod 'sdwebimage', '~> 3.4 ') copy it in and save it. The command line is as follows: cd 'your project root directory' # Open your root directory vi Podfile # Open and edit it, as shown in: after the editing is complete, Press Esc to exit the editing, and then enter ': wq' to save and exit. Now you can install the dependency in the project: pod install Tips: if you reference a large library and do not need all the files, you can write as follows: after the pod 'nimbus/core' is installed successfully, your project and the wood will generate a file like this: Make sure you can use this file to open your project later. Sometimes CocoaPods does not have the pod resources you need to create a pod. Fortunately, you can easily create a pod spec create Peanut edit Peanut. podspec pod spec lint Peanut. podspecWhen you're done, please create a ticket and upload the pod. you can also fork thecoapods specs GitHub repository and send a pull request. we really love contributions!

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.