iOS 组件化

iOS创建CocoaPods私有库

2020-08-19  本文已影响0人  灬小五灬

前言

iOS开发者,会经常使用CocoaPods管理第三方库。但是,无论是组件化开发还是需要创建公司内部的类库,我们都可以制作自己私有的CocoaPods库。本文就是详细说明私有库创建流程。

1.准备工作

2.创建pod私有库的项目工程

3.将本地文件上传到远程仓库

MacBook-Pro LWLib % git remote add origin https://gitee.com/ZhaoLaoWu/LWLib.git
MacBook-Pro LWLib % git add .
MacBook-Pro LWLib % git commit -m "Initial commit"
MacBook-Pro LWLib % git push -u origin master 
#To https://gitee.com/ZhaoLaoWu/LWLib.git
# ! [rejected]        master -> master (fetch first)
#error: failed to push some refs to 'https://gitee.com/ZhaoLaoWu/LWLib.git'
#hint: Updates were rejected because the remote contains work that you do
#hint: not have locally. This is usually caused by another repository pushing
#hint: to the same ref. You may want to first integrate the remote changes
#hint: (e.g., 'git pull ...') before pushing again.
#hint: See the 'Note about fast-forwards' in 'git push --help' for details.
#注意:当执行推送远端失败时,先执行以下操作
MacBook-Pro LWLib % git pull origin master
#From https://gitee.com/ZhaoLaoWu/LWLib
# * branch            master     -> FETCH_HEAD
#fatal: refusing to merge unrelated histories
#注意:如果出现上面所示错误,需添加--allow-unrelated-histories即可
MacBook-Pro LWLib % git pull origin master --allow-unrelated-histories
#From https://gitee.com/ZhaoLaoWu/LWLib
# * branch            master     -> FETCH_HEAD
#CONFLICT (add/add): Merge conflict in README.md
#Auto-merging README.md
#Automatic merge failed; fix conflicts and then commit the result.
# 合并README.md的冲突 然后 commit
MacBook-Pro LWLib % git add .
MacBook-Pro LWLib % git commit -m '解决合并冲突' 
# 推送更新到远程仓库
#注意:第一次推送master分支时,加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来,后续推送不需要再使用-u参数
MacBook-Pro LWLib % git push -u origin master
#Enumerating objects: 116, done.
#Counting objects: 100% (116/116), done.
#Delta compression using up to 4 threads
#Compressing objects: 100% (104/104), done.
#Writing objects: 100% (114/114), 53.17 KiB | 3.54 MiB/s, done.
#Total 114 (delta 25), reused 0 (delta 0)
#remote: Resolving deltas: 100% (25/25), completed with 1 local object.
#remote: Powered by GITEE.COM [GNK-5.0]
#To https://gitee.com/ZhaoLaoWu/LWLib.git
#   82f9eaf..b38a835  master -> master
#Branch 'master' set up to track remote branch 'master' from 'origin'.
#tag 值要和podspec中的version一致
MacBook-Pro LWLib % git tag 0.1.0
#推送tag到服务器上
MacBook-Pro LWLib % git push --tags
#Total 0 (delta 0), reused 0 (delta 0)
#remote: Powered by GITEE.COM [GNK-5.0]
#To https://gitee.com/ZhaoLaoWu/LWLib.git
# * [new tag]         0.1.0 -> 0.1.0

这是查看远程仓库已经有代码了

4.校验Spec

5.创建spec repo

6.验证

source ‘https://gitee.com/ZhaoLaoWu/LWSpec.git’
platform:ios, '10.0'
target 'CSLWLib' do
 use_frameworks!
 pod 'LWLib'
end
MacBook-Pro %  ~ % cd /Users/zhaoguian/Desktop/CSLWLib 
MacBook-Pro CSLWLib % pod install

Analyzing dependencies
Downloading dependencies
Installing LWLib (0.1.0)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

[!] Smart quotes were detected and ignored in your Podfile. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.
zhaoguian@localhost CSLWLib % 

完成

上一篇 下一篇

猜你喜欢

热点阅读