组件化过程常见问题

2018-11-07  本文已影响0人  wangyu2488

2018年10月18日
1.上传库的时候报错,第三方库无法正常下载


image.png

解决:本地库更新 (之后再上传就正常了)
pod repo update


image.png

2018年9月27日
1.已经引入头文件了,还报头文件错误


image.png

原因:头文件引入有先后顺序,正确引入即可,建议第三方工具类的放最前面

2018年9月26日
1.编译通过,做库的时候报错


image.png

原因:基本可能是配置文件 问题,如分层,需要添加依赖

s.source_files = 'HuTrainKit/Classes/*'
s.public_header_files = 'HuTrainKit/Classes/*.h'
s.prefix_header_contents = '#import <HuConfigsKit/HuConfigsHeader.h>','#import <MJExtension/MJExtension.h>','#import <HuCommonUIKit/HuCommonUIHeader.h>','#import <HuUtilsKit/HuUtilsHeader.h>','#import <HuCategoryKit/HuCategoryHead.h>','#import <HuMainProjectCategoryKit/CTMediator+HuMainProjectCategory.h>','#import <MJRefresh/MJRefresh.h>','#import <HuNetKit/HuNetHeader.h>','#import <MJExtension/MJExtension.h>','#import <IQKeyboardManager/IQKeyboardManager.h>','#import <SDWebImage/UIImageView+WebCache.h>','#import <Masonry/Masonry.h>’

s.subspec 'HuTrain' do |ss|
    ss.subspec 'Models' do |sss|
        sss.source_files = 'HuTrainKit/Classes/HuTrain/Models/*'
    end
    
    ss.subspec 'Views' do |sss|
        sss.dependency 'HuTrainKit/HuTrain/Models'
        sss.source_files = 'HuTrainKit/Classes/HuTrain/Views/*'
    end
    
    ss.subspec 'ViewControllers' do |sss|
        sss.dependency 'HuTrainKit/HuTrain/Views'
        sss.source_files = 'HuTrainKit/Classes/HuTrain/ViewControllers/*'
    end
end

对应文件夹目录


image.png

注意点:
1.很重要的原因,就是每次做库验证的时候,都要升级下tag(删除tag,在重新添加无效),不然有可能解决了问题,但还是在验证老的代码
2.工具类HuTrainUtils 由于依赖 HuScanViewController.h文件 同时又供 TrainTestNeedToKonwViewController.h使用
如果做成一个单独目录添加dependency ,这样就会导致循环引用,目前放到ViewControllers文件里解决
3.预加头文件 最好不要加入本地库使用的头文件,可能会有问题。 s.prefix_header_contents = #import "HuTrainUtils.h"
4.发现一个诡异的问题,HuTrainKit 库用到了HuCategroy 库里面 一个 containsaString方法 就一直验证不成功,
解决:先改成左边系统方法


image.png

2018年9月21日
1.验证包的时候报如下错误

已经将函数改成函数原型,这样 interface builder -build setting设置成yes也可以编译通过,不过还是报错

参考:https://blog.csdn.net/pinxue/article/details/46468039

最终解决:参考CTMediator的 podspec文件https://github.com/casatwy/CTMediator/blob/master/CTMediator.podspec

添加如下配置后,pod install后就可以验证成功了

s.frameworks = "UIKit"
image.png

2.图片库报如下错误MJPhotoBrowser 报如下错误(用了4.多的库导致)

No visible @interface for 'SDWebImageManager' declares the selector 'downloadImageWithURL:options:progress:completed:'

解决:先加载

s.dependency 'SDWebImage', '~> 3.8.0’

在加载

s.dependency 'MJPhotoBrowser'

参考:https://github.com/openshopio/openshop.io-ios/issues/14
2018年8月27日
1.多级目录分层模块

1.1sss.denpendency = 组件面+文件夹名 (不是物理路径不含Classes)
1.2如果文件夹下面只有子目录,没有文件, 不能设置ss.source_files = 'HuCommonUIKit/Classes/HuTableViewExtend/*'


image.png
#
# Be sure to run `pod lib lint HuCommonUIKit.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
  s.name             = 'HuCommonUIKit'
  s.version          = '1.0.11'
  s.summary          = '1.0.8已经成功.现做更深层次分层'
# This description is used to generate tags and improve search results.
#   * Think: What does it do? Why did you write it? What is the focus?
#   * Try to keep it short, snappy and to the point.
#   * Write the description between the DESC delimiters below.
#   * Finally, don't worry about the indent, CocoaPods strips it!
  s.description      = <<-DESC
TODO: Add long description of the pod here.
                       DESC
  s.homepage         = 'git@gitlab.317hu.com:HuModularizationLibrary/HuCommonUIKit'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'wangyu204' => 'wangyu@317hu.com' }
  s.source           = { :git => 'git@gitlab.317hu.com:HuModularizationLibrary/HuCommonUIKit.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
  s.ios.deployment_target = '8.0'
    #s.source_files = 'HuCommonUIKit/Classes/**/*'
    s.source_files = 'HuCommonUIKit/Classes/*'
    s.public_header_files = 'HuCommonUIKit/Classes/HuCommonUIHeader.h'
    s.prefix_header_contents = '#import <HuConfigsKit/HuConfigsHeader.h>','#import <HuCategoryKit/HuCategoryHead.h>','#import <HuUtilsKit/HuUtilsHeader.h>'
#-----------------文件分级---------------------#
    s.subspec 'Views' do |ss|
        ss.source_files = 'HuCommonUIKit/Classes/Views/*'
    end
    
    s.subspec 'Utils' do |ss|
        ss.dependency 'HuCommonUIKit/Views'
        ss.source_files = 'HuCommonUIKit/Classes/Utils/*'
    end
    
    s.subspec 'ViewControllers' do |ss|
        ss.dependency 'HuCommonUIKit/Views'
        ss.source_files = 'HuCommonUIKit/Classes/ViewControllers/*'
    end
    
    s.subspec 'HuTableViewExtend' do |ss|
        
        ss.subspec 'DataAdapter' do |sss|
            sss.source_files = 'HuCommonUIKit/Classes/HuTableViewExtend/DataAdapter/*'
        end
        
        ss.subspec 'VIewBase' do |sss|
            sss.dependency 'HuCommonUIKit/Views'
            sss.dependency 'HuCommonUIKit/Utils'
            sss.dependency 'HuCommonUIKit/HuTableViewExtend/DataAdapter'
            sss.source_files = 'HuCommonUIKit/Classes/HuTableViewExtend/VIewBase/*'
        end
    end
#-----------------文件分级---------------------#
  
  # s.resource_bundles = {
  #   'HuCommonUIKit' => ['HuCommonUIKit/Assets/*.png']
  # }
  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking', '~> 2.3'
    s.dependency 'HuConfigsKit'
    s.dependency 'HuCategoryKit'
    s.dependency 'HuUtilsKit'
    s.dependency 'MJRefresh', '~> 3.1.15'
end

2018年8月23日
1.本地编译OK,但是做成库就报错


image.png

原因:你本地改了第三方HucommonUIKit库,本地build ok, 但是验证库是在远端的,你需要把HucommonUIKit库更改都做成库才能正常验证。
解决:先做修改库

2018年8月20日
1.做成的库无法找到头文件


image.png

原因:左边目录结构已经分组, 右边配置设置没有分组导致


image.png

解决:


image.png

如果您发现本文对你有所帮助,如果您认为其他人也可能受益,请把它分享出去。

上一篇 下一篇

猜你喜欢

热点阅读