cocoapod其他功能

2020-08-31  本文已影响0人  刘铁崧

1. 版本库如果依赖其他库

在.podspec文件中添加

s.dependency 'AFNetworking'
s.dependency 'SDWebImage'

2. 将大版本库分割成小版本库(私有库分支)

在.podspec文件中添加

s.subspec 'Category' do |c|
  c.source_files = 'CYOCBasePod/Classes/Category/**/*'
end
s.subspec 'Base' do |b|
  b.source_files = 'CYOCBasePod/Classes/Base/**/*'  
end
# 如果有依赖其他框架的子类
s.subspec 'Network' do |n|
  n.source_files = 'CYOCBasePod/Classes/Network/**/*'  
  n.dependency 'AFNetworking'
end

如果指向安装子库:

pod 'CYOCBasePod/Category'

添加依赖记得在pod中添加source源(远程库和官方库)

3. 远程私有库使用图片

将图片放到Assets文件路径下:

podspec文件中引入asset:

  s.resource_bundles = {
    'CYOCBasePod' => ['CYOCBasePod/Assets/*']
#     'CYOCBasePod' => ['CYOCBasePod/Assets/*.png']
  }

库内部使用内部图片资源时:

NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"tabbar_bg@2x.png" ofType:nil inDirectory:@"XMGFMMain.bundle"];
UIImage *image = [UIImage imageWithContentsOfFile:path];
上一篇下一篇

猜你喜欢

热点阅读