随着对 CocoaPods 越来越多的依赖,我们也可以尝试把自己的库发布到它上面。

1.在Github上新建一个项目(名字我随便取了一个,其他步骤截图为WCUIKit)。自己做相应修改即可。

2.克隆到本地  git clone https://github.com/dianziguan1234/WCUIKit.git

Xcode创建项目。添加自己的代码。目录结构大致为

其中SourceCode存放源码部分,就是后来通过cocoapods安装以后得到的代码块。

WCUIKit存放我们Xcode创建的项目。

3.重要的一步。添加tag并提交github master分支。

git add -A && git commit -m "Release 1.0.2"
git tag '1.0.2'
git push --tags
git push origin master

4:创建podspec文件。

cd WCUIKit
pod spec create WCUIKit.podspec

之后在该目录下会生成一个 WCUIKit.podspec 文件,该文件是 Ruby 编写的,打开并编辑这个文件,填写好配置文件。

#
# Be sure to run `pod spec lint WCUIKit.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
# Pod::Spec.new do |s| # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# These will help people to find your library, and whilst it
# can feel like a chore to fill in it's definitely to your advantage. The
# summary should be tweet-length, and the description more in depth.
# s.name = "WCUIKit"
s.version = "1.0.2"
s.summary = "任意视图添加角标" # This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it! s.homepage = "https://github.com/dianziguan1234/WCUIKit"
# s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Licensing your code is important. See http://choosealicense.com for more info.
# CocoaPods will detect a license file if there is a named LICENSE*
# Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
# #s.license = "MIT (example)"
s.license = { :type => "MIT", :file => "FILE_LICENSE" } # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the authors of the library, with email addresses. Email addresses
# of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
# accepts just a name if you'd rather not provide an email address.
#
# Specify a social_media_url where others can refer to, for example a twitter
# profile URL.
# s.author = { "guanweicheng" => "1396539283@qq.com" }
# Or just: s.author = "guanweicheng"
# s.authors = { "guanweicheng" => "1396539283@qq.com" }
# s.social_media_url = "http://twitter.com/guanweicheng" # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If this Pod runs only on iOS or OS X, then specify the platform and
# the deployment target. You can optionally include the target after the platform.
# s.platform = :ios
s.platform = :ios, "8.0" # When using multiple platforms
# s.ios.deployment_target = "5.0"
# s.osx.deployment_target = "10.7"
# s.watchos.deployment_target = "2.0"
# s.tvos.deployment_target = "9.0" # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the location from where the source should be retrieved.
# Supports git, hg, bzr, svn and HTTP.
# s.source = { :git => "https://github.com/dianziguan1234/WCUIKit.git", :tag => "#{s.version}" } # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# CocoaPods is smart about how it includes source code. For source files
# giving a folder will include any swift, h, m, mm, c & cpp files.
# For header files it will include any header in the folder.
# Not including the public_header_files will make all headers public.
# s.source_files = 'SourceCode/**/*.{h,m}'
#s.exclude_files = "SourceCode/" s.public_header_files = "SourceCode/**/*.h" # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# A list of resources included with the Pod. These are copied into the
# target bundle with a build phase script. Anything else will be cleaned.
# You can preserve files from being cleaned, please don't preserve
# non-essential files like tests, examples and documentation.
# # s.resource = "icon.png"
# s.resources = "Resources/*.png" # s.preserve_paths = "FilesToSave", "MoreFilesToSave" # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Link your library with frameworks, or libraries. Libraries do not include
# the lib prefix of their name.
# # s.framework = "SomeFramework"
# s.frameworks = "SomeFramework", "AnotherFramework" # s.library = "iconv"
# s.libraries = "iconv", "xml2" # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If your library depends on compiler flags you can set them in the xcconfig hash
# where they will only apply to your library. If you depend on other Podspecs
# you can include multiple dependencies to ensure it works. s.requires_arc = true # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
# s.dependency "JSONKit", "~> 1.4" end

红色部分稍微留意下。如果需要详细文档请移步 Specs and the Specs Repo

5.验证podspec文件

cd WCUIKit
pod spec lint WCUIKit.podspec

6.注册上传到cocoapods

pod trunk register 1396539283@qq.com 'guanweicheng' --description='gwc'

pod trunk push WCUIKit.podspec

如果不出意外的话。会恭喜你发布成功。

7.然后可以pod search 你自己的库文件了。这里可能会出搜索不到的情况。参考链接解决即可(原理简单)。http://blog.cocoachina.com/article/29127

podspec文件可以参考我的项目。https://github.com/dianziguan1234/WCUIKit.git

最新文章

  1. C# NamePipe使用小结
  2. 在Hdsi2.0 SQL的注入部分抓包分析语句
  3. js阻止事件冒泡的方法
  4. JS 获取网页的宽高
  5. 【社交系统ThinkSNS+研发日记三】基于 Laravel Route 的 ThinkSNS+ Component
  6. PhpStorm代码编辑区竖线的用途以及如何去掉
  7. SQL Server Profiler 常见问题总结
  8. JavaScript资源网址
  9. 记录解决phpStudy报出403Forbidden问题的方法
  10. linq中last或者lastordefault不存在的问题
  11. javascript原生代码取单选框的值
  12. Redis为什么使用单进程单线程方式
  13. GDAL------加载Shapefile文件
  14. jQuery 概述
  15. 使用Android Ant在编译时混淆
  16. Sql 四大排名函数(ROW_NUMBER、RANK、DENSE_RANK、NTILE)
  17. Cheatsheet: 2018 01.01 ~ 02.28
  18. STM32之关闭JTAG
  19. mybatis开发dao的方式
  20. 数学 2015百度之星初赛2 HDOJ 5255 魔法因子

热门文章

  1. hihoCoder#1069 最近公共祖先·三
  2. [BZOJ1029] [JSOI2007]建筑抢修(贪心 + 优先队列)
  3. codeforces 363A
  4. 接龙游戏(codevs 1051)
  5. 获取webview的截图
  6. SQLServer时间分段查询
  7. uva 439 Knight Moves 骑士移动
  8. 公用表表达式(CTE)
  9. Netty In Action中文版 - 第四章:Transports(传输)
  10. 协议解析Bug分析