👇 👇

❤️ published in a book in 2017 from a book to move over

CocoaPods profile

This article introduces CocoaPods as a tool that allows you to build and manage your project components in a private repository. Simply put, there is a Spec Repo on GitHub that contains thousands of podSpec index directories. Then we can use it to find the open source code we need and automatically configure it during project integration.

The first time you install it, you download CocoaPods locally.

Setting up CocoaPods master repo $ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress Cloning into 'master'... remote: Counting objects: 1301071, done. remote: Compressing objects: 100% (169/169), done. Receiving objects: 98% (1275050/1301071) and 396.42 MiB | 559.00 KiB/sCopy the code

One step in the installation process is the Clone standard repository, or Master Repo for short. Projects stored in the REPo are open source, and any project found by module address is downloadable. We pass podspec file to CocoaPods master, while others are configured CocoaPods will put our podspec. Download the json to ~ /. CocoaPods/repos/master /, Users to use Alamofire find local ~ /. Cocoapods/repos/master/find the Alamofire podspec. Json file download configuration based on the content.

Module specification (.podspec file)

This article uses the Alamofire open source library as an example to describe the files CocoaPods needs to manage a project. CocoaPods locates project addresses based on module specification management.

To create a spec file for your project, execute the 👇 command on your terminal to generate a test.podspec file, keeping the module specification name and library name consistent.

$ pod spec create test
Copy the code

The most important items in the PodSpec file are tag and source, because tag is required for projects controlled by Git version in the PodSpec file. Module specification details configuration please move to the official instructions to view, which is very clear, there are more advanced configuration methods, also not as the focus of this article. CocoaPods also provides another command that connects the Demo project to our Pods project by creating an Xcode workspace for our development. 👇

$ pod lib create TestLib
Copy the code

Both POD Lib Lint and POD Spec Lint can verify that podSpecs are compliant, except that the former doesn’t need a network, while the latter validates other libraries and library tag issues. If any error or warning fails to Pass the verification, –allow-warnings allows ignoring the warning, and –verbose displays detailed information about the verification process. If Pass Validate is passed, the surface library configuration is successful and can be published.

$ pod lib lint --allow-warnings --verbose
Copy the code

Trunk service

If this is the first time we release the code base on this computer, we need to register trunk for the current computer to prepare for the later release of Pod.

$POD Trunk register [email protected] ‘Orta Therox’ –description=’macbook Air ‘

$pod trunk register [email protected] 'Serena_R'
Copy the code

Your registered email address will receive a registration email, follow the instructions to register. It will be published after the POD Spec Lint process has passed. If it is an open source library distribution, the configuration file is submitted to the CocoaPods Master Repo.

$ pod trunk push NAME.podspec
Copy the code

You can also commit to a designated private repository.

$ pod repo push REPO [NAME.podspec]
Copy the code

Create a private Spec Repo

The CocoaPods Master Repo

This repository contains the public CocoaPods specifications.

CocoaPods provides the ability to integrate with private Repo libraries. If you can create your own Specs Repo like CocoaPods and deploy your warehouse addresses to the addresses that you want to allow access to all of your members, Generally, the IP address is an Intranet address or a Private address, which can be isolated from the outside world and accessible to internal personnel. We can then use CocoaPods to manage pod components by updating our public component podSpec files to the private REPO via the POD Trunk service. For demonstration purposes, the remote address is deployed as the Github address, and the actual design process should be the address of the company's private Git server. One of the advantages of uploading to your own Repo is that due to github access speed is very unstable (tear eye), the update speed will be slow, if migrated to the domestic code hosting server speed will be greatly improved, recommend open source China code cloud. First create a repository on a remote Git server and associate it locally, then add a private Repo:Copy the code

$ pod repo add REPO_NAME SOURCE_URL

$ pod trunk push NAME.podspecpod repo push myPrivateRepo TestLib.podspec

To use it, add the following two sentences to your project’s Podfile.

source 'https://github.com/CocoaPods/Specs.git'

source 'https://github.com/Serena1993/myPrivateRepo'
Copy the code

References:

guides.cocoapods.org

www.jianshu.com/p/17d704c5a…