The resources

www.cnblogs.com/iyuanxiaoju…

Install and use CocoaPods in the following ways:

About gitignore.

When pod Install is executed, CocoaPods also generates a file named podfile. lock in addition to Podfile, which should not be added to.gitignore. Because podfile. lock locks the current version of each dependent library, subsequent iterations of pod install will not change the version, and only pod update will change podfile. lock. This prevents third-party library versions from being inconsistent with each other when third-party libraries are upgraded when multiple people collaborate.

Create podSpec files for your own projects

We can create PodSpec files for our open source projects that others can easily download. Start by initializing a podSpec file with the following command:

pod spec create your_pod_spec_name
Copy the code

After executing this command, CocoaPods will generate a file named your_pod_spec_name. Podspec, which you can then modify. For details, see Cocoapods Getting Started in this blog post.

Use private Pods

We can specify a dependent PodSpec directly so that we can use a private library within the company. This solution helps to enable CocoaPods to be supported by public projects within the enterprise. Here is an example:

pod 'MyCommon', :podspec => '[https://yuantiku.com/common/myCommon.podspec](https://yuantiku.com/common/myCommon.podspec)'
Copy the code

Don’t update podspec

By default, CocoaPods updates the PodSpec index once when pod Install and POD Update are executed. Use the –no-repo-update parameter to disable index updates. As follows:

pod install --no-repo-update
pod update --no-repo-update
Copy the code

Generate help documentation for third-party libraries

If you want CococaPods to generate help documents from third-party libraries and integrate them into Xcode, you can install AppleDoc on Brew:

brew install appledoc
Copy the code

The best thing about AppleDoc is that you can integrate the help documentation into Xcode so that when you type code, hold down the opt key and click on the class or method name to display the corresponding help documentation.

CococaPods principle

CocoaPods works by putting all of its dependencies into a separate project called Pods, and then making the main project depend on the Pods project, so that the source management work is moved from the main project to the Pods project. Here are some technical details:

  1. The Pods project will eventually compile into a file called libPods.a, which the main project only relies on.
  2. For resource files, CocoaPods provides a bash script called Pods-resources.sh that is executed every time the project is compiled to copy the various resource files from third-party libraries into the target directory.
  3. CocoaPods uses a file called Pods.xcconfig to set all dependencies and parameters at compile time.