4. cocoapods远程私有库
2017-04-25 本文已影响0人
Peuimporte
1. 设置ssh
找一个可以设置私有仓库的平台。
这里选择 coding 平台

终端敲入指令
ssh-keygen
根据提示设置,我这里直接敲回车,不设置。

打开Users/个人名称/.ssh
目录下 找到id_rsa.pub
文件,打开
讲其粘贴到 ssh公钥配置的地方。

2 添加pod 远程私有库
1. 首先创建一个私有仓库。 用来存放spec索引文件

2. 终端添加自己的远程私有库
pod repo add PodTest 远程仓库地址

打开个人目录下,查看是否添加成功

或终端敲 pod repo
查看是否添加成功
至此 索引文件整理完毕
3 开发自己的框架或者组件
终端进入组件目录下, 输入pod lib create 名称
创建一个库
按需要输入配置之后,自动打开xcode项目,将如图所示目录下文件替换为自己的框架或者组件文件

修改podSpec文件

修改完成之后可以验证一下spec文件是否配置正确
进入podspec目录,终端输入指令
pod lib lint
验证本地配置是否正确

4 上传自己的框架代码到新的远程私有库
先将当前仓库的改动使用git add commit 添加修改,然后push 到远程仓库,如果没有配置远程仓库地址,需要先配置远程仓库地址。
配置远程仓库地址:
git remote add origin [仓库地址]
将代码push 上去
给框架打tag,此处的tag 需要跟spec文件中的version一致

将tag信息推送到远程git push --tags
pod spec lint
远程配置验证。

验证成功之后,需要将自己的远程索引库,添加到pod的索引库中。
5 将自己的远程索引库,添加到本地的pod的索引库中
可以通过指令 pod repo
来查看当前电脑的Pod索引库

将索引文件push 到自己的索引库中
pod repo push TestSpec[此处是索引库名称] PodSpecTest.podspec[此处是刚才修改过的podspec文件]

push 完成之后,会自动将本地的索引库推送到远程仓库中。
输入 pod search PodSpecTest
验证Pod是否可以查找到索引
6. 如何用pods使用自己的远程私有库
如果自己的项目,没有使用pod,那么终端进入自己的项目目录下
pod init
,然后打开生成的Podfile,修改配置信息
添加索引库源。
终端输入pod repo
查看源 。将master和自己添加的源的url都添加进去, 并导入自己的Pod远程库。
导入master源是为了添加其他开发者的库。 比如AFN、SD之类的
source 'git@git.coding.net:******/PodSpec.git'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'TestPodProject' do
use_frameworks!
pod 'PodSpecTest'
end
然后终端输入pod install
, 至此,项目中就会有自己的远程仓库的代码