HXPhotoPicker icon indicating copy to clipboard operation
HXPhotoPicker copied to clipboard

组件里面以inherit! :search_paths 方式链接代码,hx_photoPickerBundle 获取不到资源

Open fanlilinSaber opened this issue 1 year ago • 0 comments

我们通过pod 正常的方式导入库对里面的资源访问是没有问题的,但是我们的组件化工程为了解决其他组件单例共享必须得使用以下方式

target 'ZJKGoods' do pod 'HXPhotoPicker/SDWebImage', '~> 3.3.1'

Pods for ZJKGoods

target 'ZJKGoods IOS Example' do # Comment the next line if you don't want to use dynamic frameworks inherit! :search_paths

# Pods for ZJKGoods IOS Example

end

end

就会造成资源hx_photoPickerBundle的资源读取问题 这边我找到了优化的代码,可以解决在以任何形式导入在工程中不会引起资源获取不到的问题。希望作者能参考优化下

#import "NSBundle+HXPhotoPicker.h" #import "HXPhotoCommon.h"

@interface HXPhotopickerBundle: NSObject @end

@implementation HXPhotopickerBundle

  • (NSBundle *)resourceBundle { static NSBundle *resourceBundle = nil; if (!resourceBundle) { NSBundle *mainBundle = [NSBundle bundleForClass:self]; NSString *resourcePath = [mainBundle pathForResource:@"HXPhotoPicker" ofType:@"bundle"]; resourceBundle = [NSBundle bundleWithPath:resourcePath] ?: mainBundle; } return resourceBundle; }

@end

@implementation NSBundle (HXPhotoPicker)

  • (instancetype)hx_photoPickerBundle { return [HXPhotopickerBundle resourceBundle]; }

fanlilinSaber avatar Aug 09 '22 10:08 fanlilinSaber