Cocoapods detailed Chenghou (iii)----production

Source: Internet
Author: User

Cocoapods Detailed----Production Wangzz original address: http://blog.csdn.net/wzzvictory/article/details/20067595 reprint Please specify the source if you feel that the article is helpful, Please leave a message or follow the public account wangzzstrive to support me, thank you!
Learn to use other people's pods rely on the library, you must be eager to create their own dependent library, today to uncover the pods rely on the library creation process of mystery. The entire creation process is an example of a view I've implemented, called the Wzmarqueeview Marquee effect, as follows: First, create your own github warehouse Cocoapods are hosted on GitHub (the official link is: https://github.com/ CocoaPods), all of the pods dependent libraries are also dependent on GitHub, so the first step is to create a github repository that belongs to us. The warehouse creation interface is as follows:
The number of the winning bid for a total of 6, the corresponding description is as follows: 1, Repository name warehouse names, written here Wzmarqueeview, required, 2, description warehouse description information, optional; 3, the openness of the warehouse can only choose public here, One is because private is to money, and then a private person can not see and share a hair; 4, whether to create a default Readme file a complete warehouse, all need to readme documentation, recommended selection. Of course, you can also manually create one later, 5, whether to add a. gitignore file. The file type is recorded in the. gitignore file, and git does not include it in version management for any file types that it contains. Whether to choose to see individual needs; 6, license type of regular warehouse should have a license file, pods rely on the library to this file more stringent requirements, it is necessary to have. So it's best to have GitHub create one here, or you can create it yourself later. The type of license I'm using is MIT.
Once the above items are complete, click the Create Repository button to create a successful interface
Here, the warehouse creation process is over.
Second, the clone warehouse to the local in order to facilitate the deletion of the contents of the warehouse, you need to clone the warehouse to the local, operating in a variety of ways, we recommend the use of the command line: [OBJC]View Plaincopy
    1. $ git clone https://github.com/wangzz/wzmarqueeview.git
Once the operation is complete, the corresponding files on GitHub are copied locally, and the directory structure is:
The. gitignore file in the repository on GitHub is a hidden file that starts with., so you can only see two of them here. All of our documents will be added, deleted and changed in this catalogue.
Third, add the required files to the local git repository to create the pods dependent libraries Note: The files described below are placed under the root directory of the local git repository in step two clone. 1. The suffix is. podspec file The file is a Pods dependent library profile, and each pods dependent library must have only one description file. The file name is consistent with the name of the dependent library that we want to create, and the file name for my Wzmarqueeview dependent library is wzmarqueeview.podspec.

1.1 Podspec File Contents

The contents of the Wzmarqueeview.podspec are:
[Ruby]View Plaincopy
  1. Pod::spec.new Do |s|
  2. S.name = "Wzmarqueeview"
  3. S.version = "1.0.0"
  4. S.summary = "A marquee view used on IOS."
  5. S.description = <<-desc
  6. It's a marquee view used on IOS, which implement by Objective-c.
  7. DESC
  8. S.homepage = "Https://github.com/wangzz/WZMarqueeView"
  9. # s.screenshots = "Www.example.com/screenshots_1", "Www.example.com/screenshots_2"
  10. S.license = ' MIT '
  11. S.author = {"Week of kings" = " [email protected]"}
  12. S.source = { : git = "Https://github.com/wangzz/WZMarqueeView.git", : Tag = s.version.to_s}
  13. # s.social_media_url = ' Https://twitter.com/NAME '
  14. S.platform = : iOS, ' 4.3 '
  15. # s.ios.deployment_target = ' 5.0 '
  16. # s.osx.deployment_target = ' 10.7 '
  17. S.requires_arc = true
  18. S.source_files = ' wzmarqueeview/* '
  19. # s.resources = ' Assets '
  20. # s.ios.exclude_files = ' Classes/osx '
  21. # s.osx.exclude_files = ' Classes/ios '
  22. # s.public_header_files = ' classes/**/*.h '
  23. S.frameworks = ' Foundation ', ' coregraphics ', ' UIKit '
  24. End
The file is a ruby file and the entries inside it are easy to know what it means. There are several parameters that need to be explained: ①s.licensepods relies on the use of the license type of library, we fill in their corresponding choices. ②s.source_files represents the path to the source file, note that the path is relative to the Podspec file. ③s.frameworks need to use the frameworks, do not need to add. frameworks suffix.

1.2 How to create a Podspec file

You can have two ways to create your own Podspec files: ①copy my podspec file and then modify the corresponding parameters, which is recommended in this way. ② executes the following creation commands: [Ruby]View Plaincopy
    1. $ pod Spec Create Wzmarqueeview
A file named Wzmarqueeview.podspec is also created. But open the created file you will find that there are too many things, many of which we do not need.
2. license file Cocoapods Mandatory all pods dependent libraries must have license files, otherwise the validation will not pass. There are many types of license, please refer to website tl;dr Legal for details. When I created the GitHub repository, I had chosen the MIT type of license.
3, the main class file creation pods relies on the library is to facilitate others to use our results, such as I want to share to everyone's Wzmarqueeview class, is I want to provide to the general user, this kind of nature is essential. I put the two files contained in this class into a folder called Wzmarqueeview, the corresponding directory structure
Contains two files: WZMarqueeView.h and WZMARQUEEVIEW.M
4, demo project in order to quickly teach others to use our pods rely on the library, usually need to provide a demo project. The demo project I created was placed in a folder named Wzmarqueeviewdemo, which contains the files as shown in:

5. readme.md people using GitHub should be familiar with this file, which is an essential part of a successful GitHub repository, using the Markdown Markup Language for detailed description of the warehouse.
The above 5 are the most basic files required to create a pods dependent library, where 1, 2, 3 are required, 4, 5 are optional but strongly recommended. When I've finished adding these files, my github local repository directory becomes as shown:

Iv. submit a modified file to GitHub after step three, add a lot of files to your local git repository, and now you need to submit them to the GitHub repository. The submission process is divided into the following steps: 1, POD authentication executes the following command: [Ruby]View Plaincopy
    1. $ set the new version to 1.0.0
    2. $ set the new tag to 1.0.0
The two commands are to add a version number to the pod and tag it. Then execute the pod Validation command: [Ruby]View Plaincopy
    1. $ pod Lib Lint
If everything is OK, the following output will appear when this command is executed: [Ruby]View Plaincopy
    1. Wzmarqueeview (1.0.0)
    2. Zmarqueeview passed validation.
This is the end of the pod validation. It is necessary to note that when the Pod verification command is executed, any warning or error messages are printed and the verification fails! If the validation is abnormal, the printed information will be detailed, and you can make changes based on the corresponding prompts.

2. Local git repository changes uploaded to the GitHub repository execute the following command in turn: [Ruby]View Plaincopy
    1. $ git add-a && git commit-m "Release 1.0.0."
    2. $ git tag ' 1.0.0 '
    3. $ git push--tags
    4. $ GIT push origin master
These commands are in the GIT category and are not described here. If all goes well, you should be able to see what you just added on GitHub. As shown in the following:


Five, upload the Podspec file to the official warehouse in Cocoapods through the front of the four steps, you may think it is over, unfortunately it is still early. To think of a pods dependent library that is really available, you need to do a final step to upload the Podspec file that we just generated to CocoaPods's official specs warehouse, linked to: https://github.com/CocoaPods/ Specs Open this link and you will find that all of the pods dependent libraries that we can use and that we can search using the pod Search command will upload their podspec files to this repository, which means Only after uploading our Podspec file to this warehouse, can we become a real pods dependent library, others can use it properly! In accordance with the rules of git, in order to add files to someone else's warehouse, you must first fork a copy of someone else's warehouse, finish the corresponding modification, push to the original author of the warehouse, wait until the author approves the pass, then merge into the original warehouse. Process understand, nature know how to do: 1, fork a copy of Cocoapods official specs warehouse into the official warehouse link, click the Fork button in the upper right corner of the screen, such as:

Then people will find themselves in the name of a warehouse branch. For example, my branch is:

2, the fork of the warehouse clone to the local execution of the following command: [Ruby]View Plaincopy
    1. $ git clone https://github.com/wangzz/Specs.git
Note that you need to replace the corresponding warehouse address with your own. This warehouse is a bit big and needs patience.
3. Add your own Podspec files to the local specs warehouse specs warehouse clone to local, it will be placed in a folder named specs. The Podspec file is stored in the specs repository as follows: Pods folder with the same name as the library---> Version number folder--->podspec file as a rule, I need to create a folder named specs under the Wzmarqueeview folder. Then go to the Wzmarqueeview folder, create a folder called 1.0.0, and finally go to the 1.0.0 folder, and copy the Wzmarqueeview.podspec files that were created. It is not difficult to understand, if later on the Wzmarqueeview class upgrade, in the Wzmarqueeview folder to establish the corresponding version name of the folder, to save the corresponding version of the Podspec file. When these operations are complete, the directory hierarchy is as follows:

4. Upload the changes from the local specs repository to the GitHub repository to execute the following command: [Ruby]View Plaincopy
    1. $ git add-a && git commit-m "add wzmarqueeview podspec file"
    2. $ GIT push origin master
You will be able to see the files you just uploaded on GitHub on your own fork in the specs warehouse.
5, will be in their fork specs to make changes to cocoapods the official specs warehouse into their fork specs warehouse, you will see the upper left corner of the screen has a green button:
The button will appear in the interface as shown in the following order:
Click on the green Create Pull request button in the image to drag the changes made on our fork specs to the Cocoapods official specs warehouse.
After this step, the rest of the work is waiting, waiting for Cocoapods's maintenance staff to review and merge our pull-up changes into the official specs warehouse, which usually has a day or so of waiting time. If there is any news, such as the audit does not pass, or approved by the Cocoapods, the official will send an email notification. By the time the audit was passed, we would be able to see the folders we had uploaded in the official specs warehouse.
6, review the audit progress of course we can also view the audit progress, open this link: https://github.com/CocoaPods/Specs/pulls, here to see all the Specs warehouse pull requests, such as:
The red circle logo is the request that I pull up just now, in order to see the corresponding audit progress.
Vi. view our own created Pods dependency library if you receive a cocoapods from the official email, you may be anxious to execute the pod Search command on your computer to see if you can search for a pods dependent library that you have created. You will be disappointed, however, because you also need to execute a command to search our dependent libraries using the search command on our local computer: [Ruby]View Plaincopy
    1. $ pod Setup
In the first article in my Cocoapods series Tutorial: Cocoapods detailed----The last part of the Advanced chapter describes this command, which will keep all pods dependent on the repository tree in the new local. Execute this command, then execute: [Ruby]View Plaincopy
    1. $ pod Search Wzmarqueeview
can show the corresponding information!
Said so much, to here the whole pods relies on the library creation process to be counted as the real end! Little friends, have you succeeded??? Please leave a message if you have any questions.
Vii. Reference Document 1, http://guides.cocoapods.org

Cocoapods detailed Chenghou (iii)----production

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.