1. 注册一个GitHub账户
2. 创建一个代码私有仓库
3. 打开终端,跳入你需要存放代码的文件夹(git的本地仓库)
4. git clone github.com/xxx/xxx.git
5. 将要分享的代码copy到git的本地仓库中
6. git add . 添加所有文件到本地仓库中
7. git commit -m "说明" commit到GitHub
8. git push origin master 推到GitHub上
9. 如果没有注册cocoapods需要注册pod trunk register [email protected] 'Your Name' --description='macbook pro'
10. pod spec create xxx 创建podspec文件
11. 修改podspec文件
a) spec.name pod库的名字
b) spec.version pod库的版本
c) spec.license pod库的开源类型
d) spec.summary pod库的简介
e) spec.homepage pod库的首页(一般为库在github的URL)
f) spec.author pod库的作者
g) spec.source pod库的资源URL(一般为当前代码在GitHub的URL)(和homepage不同的是,它有个后缀.git)
h) spec.source_files pod库的文件路径
i) spec.requires_arc pod库的代码是否是arc的
j) spec.platform pod库的对应的苹果版本 (示例 :ios, "9.0" )
k) spec.dependency pod库依赖的其他库(选填)
12. 创建一个私有repo仓库
13. Pod repo add xxx xxx(repo的名字和repo的git地址)
14. git tag -a 0.0.1 -m "更新版本0.0.1"
15. git push origin 0.0.1
16. 可以选择同时验证本地和远程pod spec lint --allow-warnings
17. pod repo push xxx(repo的名字) xxx.podspec --allow-warnings
18. 完成
19. 在导入私有库的时候需要在profile文件里添加私有库的repogit地址
20. 如果只依赖的是私有库需要在pod spec lint验证的时候带有私有库的地址,如pod spec lint --sources=httpxxxxx
21.如果既依赖的是私有库又依赖共有库需要在pod spec lint验证的时候带有私有库的地址+共有库,如pod spec lint --sources=httpxxxxx,sources=httpxxxxx
22.如果只依赖的是私有库需要pod repo push xxx(repo的名字) xxx.podspec ----sources=httpxxxxx
23.如果既依赖的是私有库又依赖共有库需要pod repo push xxx(repo的名字) xxx.podspec ----sources=httpxxxxx,sources=httpxxxxx
Podsepc示例:
Pod::Spec.new do |spec|
spec.name = "PodBase"
spec.version = "1.0.1"
spec.license = { :type => "MIT", :file => "LICENSE" }
spec.summary = "组件化私有库测试"
spec.homepage = "https://github.com/jishaowei"
spec.author = { "xiaofengwork" => "[email protected]" }
spec.source = { :git => "https://github.com/jishaowei/podbasetest.git", :tag => spec.version }
spec.source_files = "PodBase/Podbasefiles/*.{h,m}"
spec.requires_arc = true
spec.platform = :ios, "9.0"
#spec.dependency "Masonry","AFNetworking"
end
转载于:https://juejin.im/post/5d0a2787f265da1bc94ef231