选Github或者码云均可以,本例以Github为例。建立私有索引库用来做为本身组件库的索引:git
添加:pod repo add 索引库名称 索引库地址github
例:pod repo add ZYHModule https://github.com/zyhDeveloper/ZYHModule.gitbash
查询:pod repo工具
在命令行工具里cd进入桌面文件夹测试
执行:pod lib create 组件名ui
例:pod lib create XXModulesspa
咱们把基础组件相关的东西丢到Classes文件夹中,而且把ReplaceMe.m
文件删除命令行
执行:code
git rm XXModule/Classes/ReplaceMe.morm
git add .
在Example项目的Podfile文件中能够看到 “ pod 'LXFBase', :path => '../' ”,模板库已经默认帮咱们在Podfile中指定了LXFBase.podspec的位置,咱们无需操做,直接在命令行工具里cd到Example文件夹,执行pod install
标签与spec中的s.version
保持一致
git tag -a 0.1.0 -m "Release version 0.1.0"
git push origin --tags
先作个本地和远程验证
pod lib lint --allow-warnings
测试下搜索咱们的组件:pod search XXModules
cd到开发的项目工程文件
执行:pod init
// 第二行是为了保证公有库的正常使用
source 'https://github.com/zyhDeveloper/ZYHModule.git'
source 'https://github.com/CocoaPods/Specs.git'
添加:pod 'XXModules'
执行:pod install
组件库当有新增文件或者发生修改或者删除时,更新迭代执行:
删除:git rm XXXX
git add .
git commit -m '更新描述'
git push origin master
版本更新 这一步很是重要,为更新索引库作准备
git tag -a 0.2.0 -m "Release version 0.2.0"
git push origin --tags
打开你的xx.podspec
文件,将本来的版本号改成0.2.0
,与刚刚的tag保持一致
git add .
git commit -m '更新描述'
pod spec lint --allow-warnings
// pod repo push 索引库名称 xxx.podspec
pod repo push ZYHModule XXModule.podspec --allow-warnings
pod update
若是咱们只须要用到SDWebImage中的GIF功能,那么并不须要将整个SDWebImage都下载下来,在Podfile中将~~pod 'SDWebImage'
~~ 改成 pod SDWebImage/GIF
便可单独使用这一功能。
子库格式
s.subspec '子库名称' do |别名|
end
使用说明:
s.source_files = 'XXModule/Classes/*'
# s.dependency 'SDWebImage', '~> 4.3.3'主库的依赖库
s.subspec 'Cache' do |c|
c.source_files = 'XXModule/Classes/Manager/**/*'
c.dependency 'SDWebImage', '~> 4.3.3' 子库的依赖库
end
s.subspec 'Manager' do |m|
m.source_files = 'XXModule/Classes/Category/**/*'
end
修改后再按以前的步骤更新索引库和组件库就能够了
pod spec lint --allow-warnings(若是文件路径没问题,出现The`source_files` pattern did not match any file
可尝试新设置tag)
pod repo push ZYHModule XXModule.podspec --allow-warnings
pod update
如需在某个工程添加子库,可执行:
pod 'XXModule/Manager'
pod install
资源文件都放在Assets文件夹中
将关于资源加载的注释去掉
s.resource_bundles = {
# 'LXFMain' => ['LXFMain/Assets/*.png']
改成:'LXFMain' => ['LXFMain/Assets/*']
}
使用[UIImage imageNamed:@"图片名称"]加载不出来图片
使用如下代码:
若是是直接在xib中拖入一个imageView控件来设置图片的加载,咱们则须要在图片名字前加上当前bundle名称 XXXX.bundle/图片名字
本地私有索引库路径:/Users/Mr.z/.cocoapods/repos
删除私有索引库:
pod repo remove [索引库名称] //移除本地索引库