CocoaPods User Manual

Source: Internet
Author: User
Tags install cocoapods

1. Core Components

1.1 Cocoapods/cocoapod

This is a user-oriented component that will be activated whenever you execute a pod command. It includes all the utility cocoapods functions, and can also invoke other gem packages to perform tasks.

1.2 Cocoapods/core

The Core gem provides processing for cocoapods-related files (primarily Podfile and podspecs).

1.2.1 Podfile

Podfile is used to configure the third-party libraries required by the project. It can be highly customizable, so you can add as many features as you want to it.

1.2.2 Podspec

The. Podspec file describes how a library will be added to the project. The. podspec file can identify the source files, dependent libraries, compilation options, and other configuration required by the third-party library.

1.3 Cocoapods/xcodeproj

This package is responsible for the processing of the direct relationship between engineering documents. It can create and modify. xcodeproj files and. xcworkspace files. It can also be used as a standalone package, and you can consider using cocoapods/xcodeproj when you want to write a script that modifies the project file.

2. Installation and update

Installing the Cocoapods tool requires the use of gems (third-party library management tools for Ruby). GEM is supported by default in MacOS, but it is sometimes necessary to install or update cocoapods, which requires a later version of Gem Support.

[sudo] gem Update–system, upgrade gem.

chmod 775 usr/local, modify the usr/local access rights to enable the [sudo] gem install cocoapods to be installed.

3.Pod Commands

1. View pod All commands: Pod Help

2. View specific command usage: Pod <command>-help, for example: Pod try-help

3. Install and configure a third-party library: Pod install. If you want to see the specifics, pod install--verbose. A very good link:http://blog.jobbole.com/53365/.

4. Detect and update the new repository: Pod update. You can view the expired third-party open source libraries in pods via pod outdated. Pod Install & pod Update differences: For example: podfile, pod ' Svprogresshud ', without specifying this open source library version. Pod Install, if Svprogresshud already exists in pods, use it directly. However, pod update will re-download the latest version to pods.

5. Produce ' ~/.cocoapods/repos ': Pod setup. All third-party open Source Library information that it supports is maintained in the Cocoapods directory. Update, sudo rm-fr ~/.cocoapods/repos/master, and then pod Setup. You can also use Git to update.

6, search for third-party open Source Library: Pod search <open source>, search in Cocoapods this directory. You can also search for third-party libraries in http://cocoapods.org.

4.Podfile

Can be viewed in detail: http://guides.cocoapods.org/syntax/podfile.html

1. Pod ' objection ' ' version ';

For example, pod ' mcdateextensions ', which does not specify a version, will get the latest version at Pod update, pod ' mcdateextensions ' ~>1.0.0 ', and the version information obtained is [1.0.0, 1.1.0]. ~> is a reference to Ruby's syntax, ~>x.y.z, which means that the version number x, y is fixed, but can be greater than or equal to Z. The usual version number naming has its convention: X major Version number upgrade indicates that there is no backward compatibility changes in the API, Y minor version number upgrade indicates a feature added, the Z tiny version number upgrade represents Bugs remediation. Therefore, "~> x.y.z" allows us to maintain the elasticity of the upgrade, and do not upgrade too much to make the program incompatible error;

2. From the local pod files, pod ' afnetworking ',:p ath = ' ~/documents/afnetworking ' This directory must have a. Podspec document

3. From the GIT server side pod files

To use the master branch of the repo:

Pod ' afnetworking ',: git = ' https://github.com/gowalla/AFNetworking.git ',: branch = ' Develop '

Or Specify a commit:

Pod ' afnetworking ',: git = ' https://github.com/gowalla/AFNetworking.git ',: Commit = ' 082F8319AF '

4. Pod ' Sharekit/facebook ' supports the import of sub-modules.

5. What does Pod install in turn?

Steps:

http://blog.jobbole.com/53365/

6. Better git warehouse Management

Manage Podfile & podfile.lock & Workspace in a git repository

Reason:

Podfile.lock, ensure that the third-party libraries used by each team member are of the same version

Workspace, if generated by cocoapods, it is not necessary. If Workspace is created by itself, it is required.

7. Comments

Single-line Comment: #

Multi-line Comments:

=begin

Codes to comment

=end

5..podspec Syntax

1, Pod spec create ' name ' produces a name.podspec file, you can read this file carefully, familiar with. Podspec syntax;

2, Pod spec lint ' name '. Podspec used to build the. podspec file is wrong.

6. Support third-party developers will JPMSDK pod to their own project, how to do?

Address the following issues:

1. Create a. podspec file in the project and let it compile;

Compile the. podspec file using the command, Pod spec lint name. Official document: This document: http://guides.cocoapods.org/making/making-a-cocoapod.html

2, the custom. Podspec into the cocoa spec management;

I, need a account on GitHub, and fork Cocoa spec;

II. Push the change to the Fork Cocoa spec responsity;

III, new pull request, compare across forks;

3, processing JPMSDK version update; Repeat 2 of the Iii.

7. Production support install third-party static libraries Podspec and Podfile

1) How to make Podspec file reference OpenSSL:

Https://github.com/krzyzanowskim/OpenSSL

2) If you write podfile to support importing OpenSSL locally:

For example: Pod ' OpenSSL ',:p ath = '. /openssl ' (This is the path for OpenSSL locally), the package downloaded from the web has a quick openssl.podspec file and a Openssl-universal.podspec file. Remove the shortcut to open the Openssl.podspec file, rename the Openssl-universal.podspec file to Openssl.podspec, and place this file in S.name = "Openssl-universal" Modified to S.name = "OpenSSL".

Although, theoretically, you can use pod ' OpenSSL ',:p odspec = '. /openssl/openssl-universal.podspec ' mode designation, but the actual operation is not successful, do not know why.

8. Production of podspec files supporting Subspec

Reference Example Sharekit:

Https://github.com/ShareKit

9. Support for Cocoapods document viewing

link:http://cocoadocs.org

How to write your own code to produce Apple-style documents:

    1. Install the Alcatraz and Vvdocumenter-xcode two Xcode plugins,

Installing Alcatraz,link:http://alcatraz.io

Can be found under this path: ~/library/application support/developer/shared/xcode/plug-ins. Relaunch Xcode and type in//above any code yo U want to write a document to.

    1. Download the Link:https://github.com/tomaz/appledoc, install Appledoc.

or a Brew (Unix tool) installation. Installation method: Download path of CD to Appledoc; sudo sh install-appledoc.sh; sudo sh install-appledoc.sh-b/usr/bin-t ~/library/application\ support/appledoc.

3. You can enter appledoc-help on the terminal to view its usage. Simple example:appledoc./noticebandsdk--project-name noticebandsdk--project-company "Mophie-inc"--company-id COM.M Ophie-inc. Sdkdoc--output./, produces a txt in the current directory that tells you where the document is located. All document paths in Xcode: ~/library/developer/shared/documentation/docsets

10. Cleanup of the pod install after the project
    • File cleanup

Delete Podfile.lock,workspace,pods Directory

    • Project configuration Cleanup

1. Open the project to be cleaned, select build phases, delete Manifest.lock & Copy pods Resources & Run script.

2.framework&header Search Path cleanup

    • Cleanup Project Add files

Select project, to link Binary with Libraries, delete libpods.a and libpods***.a-like dynamic libraries

11.CocoaPods Utility website
    • Official website: http://cocoapods.org
    • Check Cocoapods document http://cocoadocs.org
    • StackOverflow Home: Http://stackoverflow.com/search?q=CocoaPods

GitHub Home Https://github.com/CocoaPods

CocoaPods User Manual

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.