1. 注册一个GitHub帐户
2. 建立一个代码私有仓库
3. 打开终端,跳入你须要存放代码的文件夹(git的本地仓库)
5. 将要分享的代码copy到git的本地仓库中
6. git add . 添加全部文件到本地仓库中
7. git commit -m "说明" commit到GitHub
8. git push origin master 推到GitHub上
9. 若是没有注册cocoapods须要注册pod trunk register name@example.org '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示例:
ios
Pod::Spec.new do |spec|
git
spec.name = "PodBase"
github
spec.version = "1.0.1"
组件化
spec.license = { :type => "MIT", :file => "LICENSE" }
测试
spec.summary = "组件化私有库测试"
ui
spec.homepage = "https://github.com/jishaowei"
code
spec.author = { "xiaofengwork" => "jishaoweixiaofeng@163.com" }
orm
spec.source = { :git => "https://github.com/jishaowei/podbasetest.git", :tag => spec.version }
cdn
spec.source_files = "PodBase/Podbasefiles/*.{h,m}"
blog
spec.requires_arc = true
spec.platform = :ios, "9.0"
#spec.dependency "Masonry","AFNetworking"
end