做iOS库文件打包想必一定用过pod package , 最近使用pod做依赖库在使用pod package打包时,因我做的pod lib库的podspec文件中依赖了第三库,如下:
Pod::Spec.new do |s|
s.name = 'LWDrawboard'
s.version = '1.0.0'
s.summary = 'A short description of LWDrawboard.'
。。。。。。。
s.ios.deployment_target = '8.0'
s.source_files = 'LWDrawboard/Classes/**/*'
s.resource_bundles = {
'LWDrawboard' => ['LWDrawboard/Assets/**/*']
}
s.public_header_files = 'LWDrawboard/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
s.dependency 'Masonry'
s.dependency 'SDWebImage'
end
使用pod package打包生成的 libLWDrawboard 给其他App使用时,因为其他的App的Podfile也依赖了Masonry、SDWebImage,所以使用方编译App出现了大量的 duplicate symbols ....... 冲突错误。
解决方案:
LWDrawboard 的podspec不用改,只要把在LWDrawboard的Example里Podfile也加上Masonry、SDWebImage这两个依赖,并在pod package打包之前在这个Example下执行 pod install,之后再执行pod package打包,这样打出的.a包就不会重复包含Masonry、SDWebImage的依赖。
pod package LWDrawboard.podspec --force --library --configuration=Release --spec-sources=https://gitlab.com/xxxx/xxxrepo.git,https://github.com/CocoaPods/Specs.git