美文网首页
利用CocoaPods创建私有库

利用CocoaPods创建私有库

作者: _哈哈哈哈哈哈 | 来源:发表于2021-01-27 14:05 被阅读0次

1. 在gitLab创建JSKlineChart

2.clone远程到本地

cd /Users/ahs

git clone  http://code.aihuishou.com/zhuwenqi/JSKlineChart.git

3.查看当前有哪些本地索引仓库

cd ~

cd .cocopods

open repos

4.创建本地索引库并和远程索引库做关联 

pod repo add JSKlineChart  http://code.aihuishou.com/zhuwenqi/JSKlineChart.git

5.再次查看repos,会发现多了一个索引

6.在桌面随便建一个Test文件夹,创建本地代码组件模版库

cd /Users/ahs/Desktop/Test

pod lib create JSKlineChart

7.回答问题

iOS -> Swift

你会发现自动生成了一个项目,如下:

上图中可以看到,里面有一个Example文件夹,可以删了

8. 删除索引库 JSKlineChart->JSKlineChart->Classes->ReplaceMe.m

9.编辑JSKlineChart.podspec文件,需要修改的有:

(1)a.summary 随便写个备注

(2)s.homePage 换成你的远程索引库地址 http://code.aihuishou.com/zhuwenqi/JSKlineChart

    s.source: git => http://code.aihuishou.com/zhuwenqi/JSKlineChart.git

10.把Test/JSKlineChart文件夹下面的除去.git文件夹外的所有文件拷贝到/Users/ahs/JSKlineChart,提交到远程代码并打tag

cd /Users/ahs/JSKlineChart

git add .

git commit -m "initPod"

git remote add origin http://code.aihuishou.com/zhuwenqi/JSKlineChart.git

git push origin master (push之后刷新下远程仓库地址,看代码有没有成功推送到远程)

git tag "0.1.0"

git tag (查看版本号是否提交成功)

git push --tags

注意: 一定要提交tag。不然会报"warning: Could not find remote branch 0.1.0 to clone.fatal:Remote branch 0.1.0 not found in upstream origin"的错误。这里就是把整个所有的文件提交到了远程仓库

11.通过pod spec lint --allow-warnings命令验证podspec索引文件(注: pod lib line是检索本地索引文件,pod spec lint是本地和远程库同时检索)

这里先执行个echo "4.1" >> swift_versions 

验证通过结果如下:

-> JSKlineChart(0.1.0)Analyzed 1 podspec.JSKlineChart.podspec passed validation.

12.验证通过后,pod repo push <本地索引库> <索引文件名> --allow-warnings 提交索引文件到远程索引库。注意cd到正确的push路径

pod repo push JSKlineChart JSKlineChart.podspec --allow-warings

正确输出如下:

Validating spec->JSKlineChart(0.1.0)Updating the `JSKlineChart' repoFrom https://github.com/zzyyd6316/JSKlineChart*[new branch]master->origin/master*[new tag]0.1.0->0.1.0Adding the spec to the `JSKlineChart' repo-[Update]JSKlineChart(0.1.0)Pushing the `JSKlineChart' repoTo https://github.com/zzyyd6316/JSKlineChart.git 8306a85..58890d7 master->master

13.over,在本地产看已成功

1. 现在我们新建一个项目MyPodTest导入库试试

cd /Users/ahs/Desktop/MyPodTest

pod init

2. 编辑podfile文件为

 platform:ios,'9.0'

target'MyPodTest'dopod'JSKlineChart',:git=>'http://code.aihuishou.com/zhuwenqi/JSKlineChart.git',:tag=>'0.1.0'

end

3.执行pod install,你会发现JSKlineChart已经导入了你的项目里面

4.现在就可以导入头文件进行使用了

相关文章

网友评论

      本文标题:利用CocoaPods创建私有库

      本文链接:https://www.haomeiwen.com/subject/zuqazktx.html