How do I upload my library to CocoaPods?


This article to share with you how to write their own library upload to CocoaPods, so that more small partners can easily use pod to use your class library.

How do I upload my library to CocoaPods?

Operation procedure

1. create your own project on GitHub

(Figure 1) creating a new warehouse at the home page of GitHub

How do I upload my library to CocoaPods?,
, figure 1

(Figure 2) fill in the warehouse information

How do I upload my library to CocoaPods?,
, figure 2

2. clone the project locally

The $git clone project address needs to be configured in advance: SSH key: how do I configure SSH? How about clone? Common GitHub terminal instructions?

3. put your own libraries and Demo into the Clones

(Figure 3) where WHCategory is the prepared library, and WHCategoryDemo is Demo

How do I upload my library to CocoaPods?,
, figure 3

4. use terminal CD to project

5. create.Podspec files for uploading to cocoapods

(Figure 4) $pod, spec, create, WHCategory

How do I upload my library to CocoaPods?,
, figure 4

6. edit the.Podspec file, recommend the use of sublime compiler (you can copy the following content, according to the Chinese prompt modification)

Pod:: do |s| = “libname” s.version = “version” s.summary = “a simple description of the library. =” “s.homepage (home page URL)” s.license = “MIT” = {“author name” =&gt “; the author} s.platform mailbox: IOS, =” 7 “s.source = {git: => (GIT download address)”: tag => s.version s.source_files} = “WHCategory (libname)”, “WHCategory/*.{h, m}” s.framework = “UIKit” s.requires_arc = true s.dependency = “Masonry”(end dependent libraries)

7. push the project to git (note version)

$git, add, &amp, & git, commit, -m, Release, 1.0.0., $git, tag,’1.0.0’$, GIT, push, –tags $, GIT, -A, push, origin, master

8. verify that.Podspec is valid

Spec lint ($pod if Baocuo, according to the prompt changes) truthfully can not pass, can try the following command spec lint WHTimePicker.podspec –verbose –use-libraries pod $–allow-warnings (libname into their own)

9. register trunk for uploading to cocoapods

$pod, trunk, register, (mail address), author’s name, and then go to the completed mailbox verification

The 10. release of Pod (following instruction in the library into their own)

Pod trunk push WHTimePicker.podspec $if eighth step: $pod spec lint WHTimePicker.podspec –verbose –use-libraries –allow-warnings so this step: $pod trunk push WHTimePicker.podspec –use-libraries –allow-warnings

Version 11. upgrade

Modify the.Podspec s.version for a higher version submitted to the Git, and a corresponding tag, then execute trunk push WHTimePicker.podspec terminal commands $pod or $pod trunk push WHTimePicker.podspec –use-libraries –allow-warnings

GitHub address: