"Ios-develop technical article-004" using Cocoapods to do IOS program dependency management

Source: Internet
Author: User

I. Overview of Cocoapods

As each language develops into one phase, the corresponding dependency management tools, such as the Java language Maven,nodejs NPM, are present. As iOS developers have grown, the industry has also come up with a dependency management tool for iOS programs, named CocoaPods.

The source code for the Cocoapods project is managed on Github. The project began on August 12, 2011 and, after years of development, has now become the de facto dependency management standard tool for IOS development. Developing IOS projects inevitably uses third-party open source libraries, and the advent of CocoaPods allows us to save time setting up and updating third-party open source libraries.

Before using CocoaPods, I need to:

(1) Copy the source code files of these third-party open source libraries to the project, or set them as Git submodule.

(2) For these open source libraries often need to rely on some of the framework of the system, I need to manually add these frameworks to project dependencies, for example, a network library will need to add the following framework:cfnetwork, SystemConfiguration, Mobilecoreservices, Coregraphics, zlib.

(3) for some open source libraries, I also need to set -licucore or wait for the -fno-objc-arc compilation parameters

(4) Manage updates for these dependent packages.

These physical activities, though simple, have no technical content and waste time. After using CocoaPods, I only need to put the third-party open Source Library in a file named Podfile, and then execute it pod install . CocoaPods will automatically download the source code of these third-party open source libraries and set up the corresponding system dependencies and compilation parameters for my project.

Ii. Introduction to installation and use of CocoaPods

  

Three, Cocoapods principle

Probably studied the principle of CocoaPods, which is to put all the dependent libraries into another named Pods project, and then let the main project depends on the Pods project, so that the source management work from the main project moved to the Pods project. Some of the technical details found are:

(1) The Pods project is eventually compiled into a file called LIBPODS.A, and the main project only needs to rely on this. a file.

(2) for resource files, CocoaPods provides a bash script called pods-resources.sh, which executes every time the project is compiled and copies the various resource files from the third-party library to the target directory.

(3) CocoaPods a file named Pods.xcconfig to set all dependencies and parameters at compile time.

"Ios-develop technical article-004" using Cocoapods to do IOS program dependency management

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.