1 一个子库是可以依赖另一个平级的子库的
我们给pod 库添加子库的时候,一个子库是可以依赖另一个子库的
如下
s.subspec 'defaultView' do |defaultView|
defaultView.source_files = 'commonComponent/Classes/defaultView/**/*'
defaultView.public_header_files = 'commonComponent/Classes/defaultView/**/*.h'
defaultView.dependency 'Masonry'
end
s.subspec 'TPHttpController' do |tpvc|
tpvc.source_files = 'commonComponent/Classes/TPHttpController/**/*'
tpvc.public_header_files = 'commonComponent/Classes/TPHttpController/**/*.h'
tpvc.dependency 'commonComponent/defaultView'
tpvc.dependency 'commonComponent/appConfig'
tpvc.dependency 'commonComponent/BaseViewModel'
tpvc.dependency 'remoteComponent', '0.0.3'
tpvc.dependency 'lottie-ios', '2.5.3'
end
s.subspec 'appConfig' do |appConfig|
appConfig.source_files = 'commonComponent/Classes/appConfig/**/*'
appConfig.public_header_files = 'commonComponent/Classes/appConfig/**/*.h'
end
s.subspec 'TPTextView' do |tptextView|
tptextView.source_files = 'commonComponent/Classes/TPTextView/**/*'
tptextView.public_header_files = 'commonComponent/Classes/TPTextView/**/*.h'
end
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
其中 子库 TPWriteCommentAsk 就依赖于同级的 TPTextView 库,注意,依赖同级子库的时候,
使用的是原名,而不是简称
2 子库的的简称不能以大写字母开头
[!] Invalid
commonComponent.podspec
file: formal argument cannot be a constant
…pec ‘TPTextView’ do |TPTextView|
Podspec 文件中的 代码
s.subspec 'TPTextView' do |TPtextView|
tptextView.source_files = 'commonComponent/Classes/TPTextView/**/*'
tptextView.public_header_files = 'commonComponent/Classes/TPTextView/**/*.h'
end
错误原因, 使用了大些字母开头,
正确的写法
s.subspec 'TPTextView' do |tptextView|
tptextView.source_files = 'commonComponent/Classes/TPTextView/**/*'
tptextView.public_header_files = 'commonComponent/Classes/TPTextView/**/*.h'
end
3 添加子库文件之后,在示例工程中执行pod install, 找不到子库
如图
实际文件夹中已经添加了子库文件
但是执行pod install 之后,在工程目录中看不到添加的子库文件
其原因就是,我们没有在podspec 描述文件中添加子库的配置
如图
添加过就好了