# Publishing a library to CocoaPods

Language: en
Canonical: [Publishing a library to CocoaPods](<https://allluckly.cn/en/journal/2016-04-04-publishing-a-library-to-cocoapods/>)
中文：[中文 HTML](<https://allluckly.cn/%E6%8A%95%E7%A8%BF/tuogao35>)
English: [English HTML](<https://allluckly.cn/en/journal/2016-04-04-publishing-a-library-to-cocoapods/>)
Published: 2016-04-04T00:00:00+08:00
Modified: 2026-10-23T10:34:14+08:00
Author: WzxJiang

Records the process of publishing an open-source library: preparing the GitHub project, registering with trunk, writing a podspec, checking versions and tags, validating and submitting. It also explains commonly used specification fields.

Originally credited to WzxJiang; edited and archived by Bison.

[Source listed in the original](<http://www.jianshu.com/p/88766e98e363>)

English translation of the [Chinese original](<https://allluckly.cn/%E6%8A%95%E7%A8%BF/tuogao35>), translated on 2026-10-23. The article body uses automated translation; app descriptions, historical reading notes and video subtitles receive separate editorial checks. Original publication dates, attribution, code and version notes are retained.

**Before you read** This technical note dates from 2015–2017. The examples have not been rerun as part of this archive update. Published in 2016. Commands and repository submission steps reflect the CocoaPods service as it worked then.

> "Today I wrote WZXSSL, a utility for quick string encryption, and wanted to publish it through CocoaPods. Many small details caused considerable confusion. This tutorial focuses on the likely pitfalls."

Editor: [Bison](<https://allluckly.cn/en/>)  
 Contributor: [WzxJiang](<http://www.jianshu.com/p/88766e98e363>)

## First, the intended audience for this tutorial:

> Know at least basic Git. Have CocoaPods installed on your Mac. Have a GitHub account.

If you do not meet these prerequisites…

![1](<https://allluckly.cn/images/blog/tuogao/tougao35/1.png>)  
 Result:

![1](<https://allluckly.cn/images/blog/tuogao/tougao35/2.png>)

### Let’s begin:

1. Create a project on GitHub and clone it locally.  
 Omitted.

2. Create a branch

![1](<https://allluckly.cn/images/blog/tuogao/tougao35/3.png>)

Note that this branch is not arbitrary: mine is 1.0.0. Remember that; it matters below.

3. Register with trunk

Uploading with trunk is much faster than the previous approach of branching cocoapods/specs. In Terminal, enter

```
pod trunk register youremail@email.com 'username'  --verbose
```

replace these with your email and username.  
 Run pod trunk me to check whether registration succeeded.  
 Success looks like this:

```
- Name:     xxxx
- Email:    xxxxxxxx
- Since:    xxxxxxx
- Pods:
- xxxx
- Sessions:
- xxxxxx
```

4. Configure the PodSpec  
 In Terminal, cd to your project folder.  
 Run pod spec create name, replacing name with your preferred name.  
 Open name.podspec in whichever editor you prefer, such as vim or Sublime.  
 The file contains many official comments, most of which you do not need.  
 Here is my configuration.

```
Pod::Spec.new do |s|

s.name          = "WZXSSL"
s.version       = "1.0.0"
s.license       = "MIT"
s.summary       = "Fast encryption string used on iOS, which implement by Objective-C."
s.homepage      = "https://github.com/Wzxhaha/WZXSSL"
s.author        = { "WzxJiang" => "wzxjiang@foxmail.com" }
s.source        = { :git => "https://github.com/Wzxhaha/WZXSSL.git", :tag => "1.0.0" }
s.requires_arc  = true
s.description   = <<-DESC
Fast encryption string, the current support for MD5 (16, 32), Sha1, Base64
DESC
s.source_files  = "WZXSSLTool/*"
s.platform      = :ios, '7.0'
s.framework     = 'Foundation', 'CoreGraphics', 'UIKit'  

end
```

Several parameters need explanation:  
 ①s.license  
 The licence used by the pod dependency. Choose the one appropriate to your library.  
 ②s.source\_files  
 specifies the source-file path, relative to the podspec file.  
 ③s.frameworks  
 Required frameworks, without the .frameworks suffix.

Note s.version = “1.0.0”: if the version is 1.0.0, the branch you use must also be 1.0.0.  
 Otherwise podspec validation later reports Could not find remote branch x.x.x to clone.

5. Commit the project  
 Commit your project changes to GitHub.  
 Omitted

6. Validate  
 Enter these separately in Terminal:

```
set the new version to 1.0.0  
set the new tag to 1.0.0
```

Bind the version number to a tag.

Then I recommend entering the following commands separately in Terminal:

```
pod lib lint --verbose和pod spec lint --verbose，
```

Check whether validation passes.  
 Adding --verbose displays error details if something fails.  
 A successful check reports XXXXX passed validation.

7. Submit  
 In Terminal, run pod trunk push XXXXX.podspec.  
 If all goes well, you will see

![1](<https://allluckly.cn/images/blog/tuogao/tougao35/4.jpg>)

CocoaPods review is now quick. Often, after only pod setup, pod search xxxx already finds your project.

Blog posts I consulted  
 \[Original\] [iOS: publish your code to CocoaPods step by step using Trunk](<http://www.cnblogs.com/wengzilin/p/4742530.html>) [CocoaPods explained: creating a pod](<http://blog.csdn.net/wzzvictory/article/details/20067595>)

Finally, questions are welcome in the comments. My [GitHub](<https://github.com/Wzxhaha>). If you like the project, please give it a star 🌟.

---

Recommended reading: [A beginner developer's review of 2015](<https://allluckly.cn/en/journal/2016-02-01-a-beginner-developer-s-review-of-2015/>)

