组件化练手,首先先使用CocoaPods创建本地私有库和远程私有库。
CocoaPods大家都用过,那就废话不多说了直接上,
首先在GitHub中创建一个仓库
并在你的电脑上创建一个代码文件夹,里面存放你需要的代码
上传代码
git init ----创建git
git add . -----添加代码
git commit -m '上传代码' ----将代码放进本地缓存
git remote add origin https://github.com/ZhaoRS/TestLib.git ----将本地代码与git相关联(第一次使用关联 以后就不需要关联了)
git push origin master ---将本地缓存代码推送到git上面
创建仓库的描述文件 spec
修改spec里面内容
打标签
git tag
git tag '0.0.1'
git push --tags
添加trunk
pod trunk register zhao_ruisheng@126.com 'zhaoruisheng' --verbose --开启一个ssl认证
去你所填邮箱中找到邮件 然后打开里面链接
在终端中执行 pod trunk push TestLib.podspec
之后会更新本地的索引文件,文件太多 非常慢 请耐心等待。
成功之后使用pod search TestLib 检索你的框架就行了
本地私有库的使用
创建文件
git init
git add .
git commit -m 'xx'
pod spec create LocationLib
更改创建spec文件 然后修改spec文件
s.source = { :git => "", :tag => "#{s.version}" }
去掉git源
修改podfile文件
platform :ios, '9.0'
target 'LocationTest' do
use_frameworks!
pod 'LocationLib', :path => '../LocationLib'
end
执行 pod init
远程私有库
创建一个git仓库 往里面添加一个spec文件
pod repo add ZRSPersionSpec git@github.com:ZhaoRS/ZRSPersionSpec.git 通过ssh添加spec文件关联
导出ssh ssh-keygen
个人中找到 公钥