Production of iOS CocoaPods Pods

Source: Internet
Author: User
Tags git clone repository

Production of iOS CocoaPods Pods
With the development of iOS, more and more developers begin to use CocoaPods to manage their third parties. When using Pods, I was wondering if Pods could help me more and change my development style. The following sections describe how to create Pods. (You can use the Git command to perform multiple operations in this article.) 1. Create a Repository (Repository) on Github. I believe everyone has a Github account, the Github account application details are ignored here. Meanings of the above parts: 1. Repository name code Repository name, which can also be called Pod name 2. Description code Repository Description 3. Openness of the Repository varies with individual capabilities. Public is free of charge, private charges 4. Whether to create a complete code repository of the default README file requires README 5 and whether to add it. gitignore file. the gitignore file records a number of file types. git does not include the file types contained in the file in version management. Check whether you need them. 6. There should be a license file in a regular license repository. The Pods dependency library must have stricter requirements for this file. Therefore, it is best to have github create one here, or you can create one later. The license type I use is MIT 2. Clone this repository to a local directory (Other svn tools such as SourceTree can be used) Terminal command $ git clone repository address 3. Create a local repository. podspec file (spec Specification) 1. Brief introduction. podspec file: this file is the description file of the Pods dependent database. Each Pods dependent database must have only one description file. The name must be consistent with the name of the created dependent database. 2. Example a of the podspec File

Pod::Spec.new do |s| s.name = "MethodFactory"s.version = "0.0.1"s.summary = "MethodFactory is a Good Factory of Method." s.description = <<-DESCMethodFactory is a Good Factory of Method ,it has too much nice method.DESC s.homepage = "https://github.com/yanglei3kyou/MethodFactory"# s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" s.license = "MIT"# s.license = { :type => "MIT", :file => "FILE_LICENSE" } s.author = { "yanglei3kyou" => "yanglei3kyou@126.com" }# Or just: s.author = "yanglei3kyou"# s.authors = { "yanglei3kyou" => "yanglei3kyou@126.com" }# s.social_media_url = "http://twitter.com/yanglei3kyou" s.platform = :ios s.source = { :git => "https://github.com/yanglei3kyou/MethodFactory.git", :tag => "0.0.1" } s.source_files = “MethodFactory/**/*.{h,m}" # s.public_header_files = "Classes/**/*.h" s.resources = "MethodFactory/*.png" # s.preserve_paths = "FilesToSave", "MoreFilesToSave" s.frameworks = "Foundation", "UIKit" s.requires_arc = true end 

 

The B parameter explains that the s. licensePods dependent library uses the license type s. source_files to indicate the path of the source file. Note that this path is relative to the podspec file. The. frameworks suffix is not required for s. frameworks. 3. Create. podspec file (in the Git repository root directory) a. Create the file and enter the content (the sample content above ), modify the B Terminal command $ pod spec create Method according to the content. 4. About the LICENSE file CocoaPods, all Pods dependent libraries must contain the license file. Otherwise, the CocoaPods official release will not pass verification. There are many types of license. When you create a github repository, you have selected a license of the MIT type. 5. The creation of Pods dependent libraries for main class files is to make it easier for others to use our results. For example, the MethodFactory class that I want to share with you is provided to users, this class is naturally essential. I put the two files contained in this class into a folder named MethodFactory, corresponding to the directory structure 6. About the Demo project in order to quickly teach others to use our Pods dependency library, A Demo project is usually required. The Demo project I created is saved to a folder named MethodFactoryDemo. The files in this directory are shown in: 7. About README. people who use github in md should be familiar with this file. It is an essential part of a successful github repository. It uses the markdown markup language to describe the repository in detail. After adding the above file, the Github local repository directory is shown in figure 8. Submit the local repository to Github 1. pod verification $ set the new version to 1.0.0 $ set the new tag to 1.0.0 $ pod lib lint note: if any warning or error message is displayed during pod verification, the verification will fail. Please follow the prompts, modify. 2. Upload $ git add-A & git commit-m "Release 1.0.0. "$ git tag '1. 0.0 '$ git push -- tags $ git push origin master 9. If this Pods is not released, use the Pods directly. If this Pods is not planned to be released in CocoaPods, you can add and use the Pods directly in the project's Podfile file. Pod 'methodfactory ',: git => 'https: // github.com/yanglei3kyou/MethodFactory.git' 10. Upload the pod spec file to the CocoaPods official repository. If you plan to use the Pods dependency library in CocoaPods, you need to upload the podspec file to the official CocoaPods specs repository. The link is https://github.com/cocoapods/specs. According to git rules, to add files to others' repositories, you must first fork a repository of others. After making the changes, push the changes to the repository's original author, wait until the author passes the review and then merge it into the original warehouse. 1. fork a copy of The CocoaPods official Specs repository. Go to the official repository link and click the fork button in the upper-right corner, for example: then, you will find that you have an additional warehouse branch under your name. For example, if my branch is: 2, clone the fork repository to the local machine $ git clonehttps: // github.com/yanglei3kyou/specs.gitthree important stories: replace the corresponding repository address with your own repository address, replace the corresponding repository address with your own. 3. Add your podspec file to the local Specs repository and clone it to the local directory. Then, the file will be placed in a folder named Specs. The principle of saving podspec files in the Specs repository is: Pods dependent library folders with the same name-> Version folders with the same name-> podspec files according to this principle, you need to create a folder named MethodFactory under the Specs folder, then go to the MethodFactory folder, create a folder named 1.0.0, and enter the folder 1.0.0. copy the podspec file. It is easy to understand that if you upgrade the MethodFactory class in the future, you can create a folder with the corresponding version name under the MethodFactory folder to save the podspec file of the corresponding version. 4. Upload the modifications from the local Specs repository to the github repository $ git add-A & git commit-m "Add MethodFactory pod spec file" $ git push origin master to execute the preceding commands, after successful upload, you can view the uploaded file in the Specs repository of fork on github. 5. Change pull on the Specs of your fork to the official Specs repository of CocoaPods and enter the Specs repository of your fork. A green button is displayed in the upper-left corner of the screen: new pull request. After clicking it, another page will be displayed. Click the green Create Pull Request button to send the modified pull on our fork Specs to the official Specs repository of CocoaPods. After this step, the rest of the work will only wait. Wait for CocoaPods maintenance personnel to review and merge the modifications we made on pull to the official Specs repository, this process usually takes about one day. CocoaPods will send an email to notify you of any message, such as rejected or approved. When the review is passed, we can see the uploaded folder in the official Specs repository. 6. view the review progress link: https://github.com/cocoapods/specs/pulls. now we can see all the specswarehouse pullrequest 11. view our own Pods dependency library and use $ Pod setup to update the local Pods dependency library Tree. Then, use the $ pod search MethodFactory command to search.

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.