组件化开发 发布自己的 CocoaPods

时间:2020-05-29
本文章向大家介绍组件化开发 发布自己的 CocoaPods,主要包括组件化开发 发布自己的 CocoaPods使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1.注册自己的 cocoapods 账号 

  pod trunk register xxxxxxxx@163.com 'name' --verbose

2.确认邮件

  [!] Please verify the session by clicking the link in the verification email that has been sent to you_email

  注:我用了qq邮箱注册 很长时间没收到邮件    换了163邮箱就立即收到邮件 

3.确认是否注册成功

   $ pod trunk me

  - Name:     foolish-an

  - Email:    xxxxxxxxxx@163.com

  - Since:    May 28th, 03:25

  - Pods:   None

  - Sessions:

    - May 28th, 03:25 - October 3rd, 21:31. IP: 163.127.64.39

4. 创建仓库

 在github上创建自己的仓库

   创建完成后clone到本地

 5.创建.podspec文件

   $ pod spec create 仓库名

 6.编辑 .podspec文件

   必要信息:

Pod::Spec.new do |s|

s.name = "DLShadowView"
s.version = "0.0.1"
s.summary = "A simple tool"
#s.description = <<-DESC
# DESC
s.homepage = "https://github.com/foolish-an/DLShadowView"
s.license = "MIT"
s.author = { "xxxxxxxxxxxx@163.com" => "xxxxxxxxxxxx@163.com" }
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/foolish-an/DLShadowView.git", :tag => "0.0.1" }

s.source_files = "DLShadowView/*.{h,m}"
end

7.验证.podspeec 文件

 $ pod lib lint

8.创建标签 推送代码

 注意标签要与.podspeec文件里边version 保持一致

9.发布到cocoapods

  pod trunk push DLShadowView.podspec

踩坑注意:github创建仓库要选择license 为MIT类型

s.source_files  文件路径是相对于.podspec 文件的

** 是匹配所有目录,
* 匹配文件,
.{h,m} 匹配后缀是 .h 或 .m 的文件

然后 Classes 须和 podspec 同级的存放你的库文件的目录, 这里 我存放库文件的目录 是 DLShadowView, 且里面已经是.h & .m的文件, 即我的  s.source_files = "DLShadowView/*.{h,m}"

若你的目录下还有很多子目录比如 util, tool, 可以写成

s.source_files = "Classes/util/*.{h,m}"
s.source_files = "Classes/tool/*.{h,m}"
或者
s.source_files = "Classes/**/*.{h,m}"

原文地址:https://www.cnblogs.com/foolish-guo/p/12986654.html