pod 添加子库需要注意的事项(二)

1 下面这个报错

  • ERROR | [commonComponent/TPWriteCommentAsk,commonComponent/SkinManager] xcodebuild: Returned an unsuccessful exit code. You can use --verbose for more information.
    - NOTE | [iOS] [commonComponent/TPWriteCommentAsk] xcodebuild: commonComponent/commonComponent/Classes/TPWriteCommentAsk/writeCommentAndAskController.m:17:9: fatal error: ‘commonComponent/CoreAnimationEffect.h’ file not found
    - NOTE | [iOS] [commonComponent/TPWriteCommentAsk] xcodebuild: commonComponent/commonComponent/Classes/TPWriteCommentAsk/writeCommentAndAskController.m:17:9: note: did not find header ‘CoreAnimationEffect.h’ in framework ‘commonComponent’ (loaded from ‘/Users/liubo/Library/Developer/Xcode/DerivedData/App-admffpvqlgjmrecbfyxtjkcbqwef/Build/Products/Release-iphonesimulator/commonComponent’)
    - NOTE | [iOS] [commonComponent/SkinManager] xcodebuild: commonComponent/commonComponent/Classes/SkinManager/TPSkinManager.m:19:9: fatal error: ‘Masonry/Masonry.h’ file not found
    [!] The commonComponent.podspec specification does not validate.

pod 添加子库需要注意的事项(二)_第1张图片
原因:没有给子库添加依赖库,但是子库的代码中却用到了依赖库

这是 子库pod 的声明代码

  s.subspec 'TPWriteCommentAsk' do |writecommentAsk|
      writecommentAsk.source_files = 'commonComponent/Classes/TPWriteCommentAsk/**/*'
      writecommentAsk.public_header_files = 'commonComponent/Classes/TPWriteCommentAsk/**/*.h'
      writecommentAsk.dependency 'remoteComponent', '0.0.3'
      writecommentAsk.dependency 'commonComponent/TPTextView'
      writecommentAsk.dependency 'Masonry'
  end
  

依赖的库中没有声明 CoreAnimation 但是,TPWriteCommentAsk的文件中引用了 CoreAnimation 库的文件,只是编译的时候,由于文件存在,并不会报文件找不到的错误,但其实依赖逻辑是需要的

修改方法: 给子库添加依赖

  s.subspec 'TPWriteCommentAsk' do |writecommentAsk|
      writecommentAsk.source_files = 'commonComponent/Classes/TPWriteCommentAsk/**/*'
      writecommentAsk.public_header_files = 'commonComponent/Classes/TPWriteCommentAsk/**/*.h'
      writecommentAsk.dependency 'remoteComponent', '0.0.3'
      writecommentAsk.dependency 'commonComponent/TPTextView'
      writecommentAsk.dependency 'Masonry'
      writecommentAsk.dependency 'commonComponent/CoreAnimation'
  end
![请添加图片描述](https://img-blog.csdnimg.cn/4536a2b34bd743ae8e4a6fcf880d1e29.png)

pod 添加子库需要注意的事项(二)_第2张图片

2 如果依赖添加了,但是格式添加的不对,也会报上面的错误

错误依赖代码

  s.subspec 'TPWriteCommentAsk' do |writecommentAsk|
      writecommentAsk.source_files = 'commonComponent/Classes/TPWriteCommentAsk/**/*'
      writecommentAsk.public_header_files = 'commonComponent/Classes/TPWriteCommentAsk/**/*.h'
      writecommentAsk.dependency 'remoteComponent', '0.0.3'
      writecommentAsk.dependency 'commonComponent/TPTextView'
      writecommentAsk.dependency 'Masonry'
      writecommentAsk.dependency 'CoreAnimation'
  end

pod 添加子库需要注意的事项(二)_第3张图片

正确的格式应该为 ‘总库名称/子库名称’

正确代码

  s.subspec 'TPWriteCommentAsk' do |writecommentAsk|
      writecommentAsk.source_files = 'commonComponent/Classes/TPWriteCommentAsk/**/*'
      writecommentAsk.public_header_files = 'commonComponent/Classes/TPWriteCommentAsk/**/*.h'
      writecommentAsk.dependency 'remoteComponent', '0.0.3'
      writecommentAsk.dependency 'commonComponent/TPTextView'
      writecommentAsk.dependency 'Masonry'
      writecommentAsk.dependency 'commonComponent/CoreAnimation'
  end

pod 添加子库需要注意的事项(二)_第4张图片

你可能感兴趣的:(xcode,ios,objective-c)