CocoaPods: Building a private warehouse and cocoapods private warehouse

Source: Internet
Author: User

CocoaPods: Building a private warehouse and cocoapods private warehouse

CocoaPods is an excellent third-party package management tool in IOS and Mac. It is similar to java maven and brings great convenience to project management.

Individuals or companies will accumulate many reusable code packages during the development process. Some of them do not want to be open-source, and they can be managed in CocoaPods like open-source libraries, therefore, it is necessary to manage a private repository.

CocoaPods is not very familiar with it. It is recommended that you refer to Tang Qiao's blog: Baidu/

By default, CocoaPods can only manage git-based code. To manage code using svn or mercurial, you need to install some plug-ins: https://github.com/clarkda/cocoapods-repo-svn

The following methods are based on git. 1. Create a code repository and push your own code to the git server. If the code can be open-source, it can be hosted by github. Refer to our open source code: https://github.com/agdsdl/DLSlideView

2. Add a version tag to the stable code. Generally, the version number is used as the tag name.
$ git tag -a <version>
Push tag to git Server
$ git push --tags
Here, <version> is generally similar to version 1.0.2. See here for the specification of the version number: http://semver.org/lang/zh-CN/
3. Create a spec file and run it in shell:
$ pod spec create <name>
The <name>. podspec file will be created in the current directory. The created file is a complete configuration template, which can be understood Based on the literal meaning and comments. You can go to the terminal.
4. verify the validity of the spec file after the spec file is modified, run
pod spec lint <name>.podspec
Modify your spec file or code according to the output prompt until you can pass the code.
5. Create spec repository (spec repository) in addition to the code repository created above, you also need to create a spec repository to store spec. The directory structure should comply with the following specifications:
├── Specs    └── [SPEC_NAME]        └── [VERSION]            └── [SPEC_NAME].podspec
Example:
├─Specs    ├──QueryKit/    ├── 0.8.0    │   └── QueryKit.podspec    ├── 0.8.1    │   └── QueryKit.podspec    ├── 0.8.2    │   └── QueryKit.podspec    └── 0.8.3    └── QueryKit.podspec    URITemplate    ├── 1.0.0    │   └── URITemplate.podspec    └── 1.0.1    └── URITemplate.podspec
The version number must match the tag in the code repository one by one. Push it to the git server, refer to our open source code: https://github.com/agdsdl/Specs
6. Add private repo to CocoaPods
$ pod repo add REPO_NAME SOURCE_URL

7. Verify that the private repo installation is correct:
$ cd ~/.cocoapods/repos/REPO_NAME$ pod repo lint .
To add a new package to REPO_NAME, run the following command:
$ pod repo push REPO_NAME SPEC_NAME.podspec
To delete a private repo:
$ pod repo remove [name]

8. Add the package to the project's Podfile as follows:
source 'https://github.com/agdsdl/Specs.git'source 'https://github.com/CocoaPods/Specs.git'platform :ios, "7.0"target "XXX" dopod 'DLSlideView','~>0.8.1'end

9. That's it! Next, run the test: run it in the project directory.
$ pod update
After the dependency package is updated, open the workspace file and click Go!
Some pitfalls: It's easy to mix spec repository and code repository. I 've been here for a long time at the beginning. Code repository is the code repository. we upload the package code to this repository. Spec repository is the configuration repository. All configurations are stored in this repository by package name and version number. This repository is only used to store spec files without code. Spec repository can be stored locally without the git server, but it seems that you must use git init to initialize this directory. Something detailed can be viewed here: https://github.com/CocoaPods/CocoaPods/issues/3041

Steps 1 to 8 only need to be executed on the local machine. Other people in the team only need to update the Podfile to directly use the private repository.

Related Article

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.