如何将自己的库上传到GitHub上,并用cocoapods管理下载

1.将代码上传至GitHub

1.1创建仓库,并且添加 MIT License,后面上传cocoapods需用到

1.2拿到自己的仓库地址,如https://github.com/zhiyuehl/HLChartView.git。下载到sourcetree。上传自己的代码,HLChartView文件就是我们需上传到cocoapods的库

2.创建podspec文件,上传cocoapods

2.1创建podspec文件,创建成功如上图。进入到你的文件,

然后使用下面命令,然后就如上图了。

pod spec create HLChartView


2.2 使用xcode打开 HLChartView.podspec文件,修改其中部分代码如下

s.name        = "HLChartView"

s.version      = "1.0.0"

s.summary      = "chart collection"

s.description  = <<-DESC

                              A collection of t highly custom chart (histogram, pie chart, line chart)

                           DESC

s.homepage    = "https://github.com/zhiyuehl/HLChartView"

s.license      = "MIT"

s.author            = { "zhiyuehl" => "775445353@qq.com" }

s.ios.deployment_target = "8.0"

s.source      = { :git => "https://github.com/zhiyuehl/HLChartView.git", :tag => "#{s.version}" }

s.source_files  = "ChartDemo/HLChartView/*.{h,m}"

s.requires_arc = true

s.description :简介,注意格式。不能再同一行编辑

s.homepage:你的库的github地址

s.author:作者。没有cocoapods账号。请先注册 终端使用  pod trunk register 邮箱地址 ‘用户名’ ,成功后就去看自己邮件

pod trunk register 775445353@qq.com 'zhiyuehl'

可以使用 pod trunk me查看自己的cocoapods账号

s.license:证书,上面创建的MIT

s.source:你的库下载地址https://github.com/zhiyuehl/HLChartView.git

s.source_files  :上传cocoapods的库文件 ,相对于HLChartView.podspec的文件路径。如果在同级,直接

"HLChartView/*.{h,m}"就行


2.3修改完成后,然后终端

pod lib lint HLChartView.podspec --allow-warnings

--allow-warnings忽略警告,请确保自己的podspec文件的正确性

当看到当看到HLChartView passed validation之后,就说明验证通过了。

2.4.github上创建release

2.5上传至cocoapods

pod trunk push HLChartView.podspec --allow-warnings

等待。然后就大功告成了。

2.6 tell your friends  高度自定义图表HLChartView

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容