iOS组件化之制作私有库
1.先创建项目库 打开终端输入
pod lib create xxx
1.1 输入相关信息之后,xcode会自动打开该工程.
1.2 找到配置文件
xxx.podspec
1.3 打开配置文件并且根据自己实际情况配置
s.version = '0.0.1' #版本号,需要与传到远端的tag一致
s.homepage = 'github.com/xxx/xxx' #所在github的库的主页
s.source_files = 'xxx/**/*' #源文件路径
s.frameworks = 'UIKit', '' #对系统库的依赖
s.dependency = '','' #对第三方库的依赖
1.4 配置完成,打开项目文件.把我们需要上传的代码文件拉到xxx -> xxx -> Classes文件夹下
1.5 然后 cd 进入到Example 文件中 pod install 安装下我们的组件
1.6 把本地库上传到github
a. cd 到工程xxx目录下
b. git remote add origin git@github.com:x/xxx.git #和远端仓库建立联系
c. git add . #把本地添加文件加入缓存区
d. git commit -m 'update' #提交代码到本地仓库
e. git push -u origin master -f #推送到github master分支
f. git tag 0.0.1 #(注意,这里的tag必须和.podSpec文件的版本一致)
g. git push --tags
1.7 创建一个私有的github索引库(用来cocoapods导入使用)
a. pod repo add 私有组件名称 索引库远程地址
执行完 本地Cocoapods索引库会出现xxx文件夹(/Users/xxx/.cocoapods/repos/)
b. 把自己私有库的索引添加到自己私有库中
pod repo push xxx xxx.podspec --allow-warnings
执行完命令 索引库里面会多一个版本0.0.1
1.8 cocoapods使用
# 注意该库地址是索引地址
pofile中添加 source 'https://github.com/xxx/xxx.git'
pod install 就可以了