组件化-引入图片sepc依赖及tag删除
2018-06-04 本文已影响3人
coderST
- 1 : 在上一期我们已经引入了测试工程
pod lib creat ...
在模板中我们会发现有Assets
这样一个文件夹,这里就是我们放图片的地方. - 2 : 我们把图片放到这个文件夹下,如果图片不好取,介绍一款好用的工具
https://github.com/steventroughtonsmith/cartool
用法在这里→https://yiweifen.com/html/news/WaiYu/124040.html
取出所有的资源以后 - 3 : 配置spec文件
- 3.1 : 打开spec你会发现下面代码,把#去掉
# s.resource_bundles = {
# 'EmojiToolModel' => ['EmojiToolModel/Assets/*.png']
# }
- 4 : 此时在pod里加载图片的方法
imageName
都加载不了图片,原因是由于imageName
这个方法从mainBundle
里加载,可现在的图片资源不再mainBundle
了- 4.1 : 注意imageName的名称要写全
NSBundle *currentBundle = [NSBundle bundleForClass:[self class]];
NSString *imagePath = [currentBundle pathForResource:@"xd_bg@2x.png" ofType:nil inDirectory@"XDMain.bundle"];
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
self.backImage = image;
-
5 : 如果业务组件依赖着基础组件,在验证本地spec的时候会报错,说依赖的基础组件找不到,是因为验证本地的时候我们没有指定source源在哪里,这个问题直接过去,因为在验证远程spec的时候会自动帮我们验证source.
-
6 : 如果tag的某个版本是错误的,最好不要继续在打tag,因为如果同事就用的你这个错误内容的tag,会报错,所以在删除当前tag和远程tag,修复好代码在重新打tag
git tag ->查看本地tag
git tag -d 0.1.0 ->删除本地0.1.0tag
git tag ->查看本地tag
git push origin :0.1.0 ->删除远程tag
清理pod 缓存pod cache clean --all
- 7 业务组件建议做好统一披露API,方便后续组件间的通讯.