CocoaPods private warehouse creation (ultra detailed)

This article is published in BY Blog, Jane reprint please keep an article on the link “CocoaPods public warehouse creation”


The recent reference to a large number of online CocoaPods private warehouse tutorial, according to the tutorial to get the pod warehouse is such a ~

CocoaPods private warehouse creation (ultra detailed)

The code and the version are mixed up, it’s just too bad

Although it can be used, but the CocoaPods itself and the structural design is not consistent.

In the last article, “the creation of the CocoaPods public warehouse,” we learned that the master directory only stored in the description of the code library, rather than storing the code. Like this

CocoaPods private warehouse creation (ultra detailed)

The code is stored in the repository

CocoaPods private warehouse creation (ultra detailed)

A lot of people do not understand the work principle of CocoaPods copy and paste someone else’s tutorial to do tutorial

Tucao end, enter the text


Create version Library (repo)

First, create a master like version of the GIT description file storage warehouse, because it is a private git warehouse, we choose oschina to create a remote private warehouse (for free) or they can be created in the GitHub ($7/month).

Take oschina as an example

Create repository

CocoaPods private warehouse creation (ultra detailed)

Back to the terminal, adding the remote private version repository to the local, repo is the abbreviation of the repository repository.

$pod repo MyRepo add

View in the Finder directory ~/.cocoapods/repos, can be found to add a MyRepo repository

CocoaPods private warehouse creation (ultra detailed)

Create code library

Back to oschina to create a private library

Add MIT License and README when creating

CocoaPods private warehouse creation (ultra detailed)

The warehouse is cloned to the local, add your code files, warehouse name.Podspec description file, and.Swift-version.

as follows

CocoaPods private warehouse creation (ultra detailed)

.swift-version file used to know swift version, with the command line to create

$echo "3" >.Swift-version

.podspec file is your pod description of the code library, you can create a blank template through the pod command:

$pod spec create MyAdditions

Or it is strongly recommended that you copy the following template directly

Pod:: do |s| = "MyAdditions" # project: s.version = "0.0.1" # version and your warehouse tag number corresponding to s.license = "MIT" # open source certificate s.summary = "private pod code" # project s.homepage = " baiyingqiu/MyAdditions" # warehouse homepage s.source = {=>: git; ", tag: =>" #{s.version} "}# your warehouse address with the SSH address, s.source_files =" MyAdditions/*.{h, m} "# your code position, BYPhoneNumTF/*.{h,.H and m} said BYPhoneNumTF folder.M file s.requires_arc = true # all ARC enabled: s.platform = IOS," 7 "and # platform support the minimum version of s.framew # Orks = "UIKit", "Foundation" # support framework # s.dependency = "AFNetworking" User = # dependent libraries # {"BY" => "[email protected]";} # author s.social_media_url = "" # personal homepage end

Here I would like to talk about a pit, with the oschina to create a private warehouse, in the verification may not find the MIT LICENSE certificate, the

S.license = "MIT" modified to specify file s.license = {type => "MIT", "file", "LICENSE"}

Then start to verify that our warehouse is configured correctly and modify it as required

$pod lib lint

General error warning, need to add –private or –allow-warnings, you can verify

$pod lib lint --private

After successful verification

-> MyAdditions (0.0.1) MyAdditions passed validation.

Push the description file to the repository

Label the project to the remote warehouse, the label number and version number corresponding to 0.0.1

Finally, we describe the description of our code repository, push, into our repository

$pod repo MyRepo push MyAdditions.podspec

At this time, the remote warehouse will be verified, the success will be found in the ~/.cocoapods/repos/MyRep new warehouse description information

CocoaPods private warehouse creation (ultra detailed)

If there is an error message

[repo] The `MyRepo` `../.cocoapods/repos/MyRepo` is not at clean

Update our repository,

$pod repo update MyRepo

Then continue to upload.

Pod repo push MyAdditions.podspec is the process of MyRepo

  1. Verify MyAdditions.podspec file
  2. Pull remote version library MyRepo
  3. Add MyAdditions.podspec to the repository
  4. Push to remote

After the completion of the search we can search in pod

$pod search MyAdditions

-> MyAdditions (0.0.1) Some category of the framework and UIKit pod'MyAdditions','~> 0.0.1' - Homepage: - Source:; - Versions: 0.0.1 [MyRepo repo] (END)

Use of private pod Libraries

The use of private pod libraries need to add this sentence in Podflie, indicating that your repository address.

Source ''

Note that the address of the repository, rather than the address of the code base

If there is also the use of a public pod library, you need to bring the public library address

Source ''

The final Podflie file becomes this way

Source '' source '' platform: IOS,'8.0'target do "MyPodTest" use_frameworks! Pod "BYPhoneNumTF" pod "MyAdditions" # public library # our private library pod "BYAdditions" # this is me and added to the repository in another code library end


$pod install

When loading is complete, you can see that the code has been integrated into our project


CocoaPods private warehouse creation (ultra detailed)

Back to the Fender in ~/.cocoapods/repos, you will find that repos has added a pod version of the library.

CocoaPods private warehouse creation (ultra detailed)

When executing the pod install command

  • Will pull the remote Podflie source tag library to the local repos folder
  • Search our pod ‘MyAdditions’ MyAdditions.podspec file in the repository.
  • According to the source address described in the MyAdditions.podspec file to download and integrate into the project


Through the creation of CocoaPods private warehouse and the creation of CocoaPods public warehouse, these two articles, I believe we have a deeper understanding of the working principle of CocoaPods.

In the process of blogging and creating, on a lot of pit (left the previous tutorial), a lot of things only you can really understand the operation end.

Finally, if there is any error in this article or what is the different point of view welcome to exchange. ?