pod组件化验证报错

1.图片资源加载

UIImage+Bundle.m
/**
 组件加载图片时必须使用此方法
 NSClassFromString(@"CommonTools") CommonTools必须保证存在于此组件
 每个组件需要定义自己的图片加载方法
 */
+ (UIImage *)CommonImageNamed:(NSString *)imageName {
    NSBundle *mapBundle = [NSBundle bundleForClass:NSClassFromString(@"CommonTools")];
    NSURL *url = [mapBundle URLForResource:@"BYHCommon" withExtension:@"bundle"];
    if (!url) {
        NSLog(@"未获取到正确bundle:%@",mapBundle.description);
        return [UIImage new];
    }
    NSBundle *imageBundle1 = [NSBundle bundleWithURL:url];
    UIImage *image = [UIImage imageNamed:imageName inBundle:imageBundle1 compatibleWithTraitCollection:nil];
    return image;
}

2.组件相互引用时需要在podspec 和 podfile中均添加

.podspec
    s.dependency 'BYHCommon'
    
podfile
    pod 'BYHCommon', :path => '../../BYHCommon'

3. The spec did not pass validation, due to 1 error.

podspec文件书写规范:
字段 s.verson, s.source 中的 tag与github创建的release版本号不一致导致, 修改为一样即可!

https://www.jianshu.com/p/283584683b0b?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

4. Encountered an unknown error (Unable to find a specification for xxxx depended upon by xxxx

可以在验证和提交的时候多写一个参数: --sources
需要带上官方的源和私有库podspec地址:
(最好加上--skip-import-validation)

pod lib lint BYH_SFJH.podspec --verbose --allow-warnings --sources='https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git,https://gitee.com/component-practice/bypodspecs.git' --skip-import-validation
pod spec lint BYH_SFJH.podspec --verbose --allow-warnings --sources='https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git,https://gitee.com/component-practice/bypodspecs.git' --skip-import-validation

5.xcodebuild: Returned an unsuccessful exit code

1.检查依赖组件的图片资源是否未抽离出到Assets
2.修改之后打tag 验证 pod repo push到本地pod仓库和远程, 之后再验证

6.The 'Pods-BYH_SFJH_Example' target has transitive dependencies that include statically linked binaries: (ZFPlayer and IJKMediaFramework)

podfile: 有静态库的话 不能添加 use_frameworks!
podspec添加: s.static_framework = true
build setting --> Linking --> Runpath Search path 加上 /usr/lib/swift

7. 关于目录问题

当Classes下面只有一个文件夹AAA时,在Xcode目录下不会显示文件夹AAA,至少需要两个文件夹,可使用Modules、Public作为统一文件目录


截屏2022-04-07 15.38.38.png

你可能感兴趣的:(pod组件化验证报错)